Skip to content

RespWriterWrapper incorrectly handles 100 Continue response #6912

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
VirrageS opened this issue Mar 11, 2025 · 1 comment · May be fixed by #6913
Open

RespWriterWrapper incorrectly handles 100 Continue response #6912

VirrageS opened this issue Mar 11, 2025 · 1 comment · May be fixed by #6913
Labels
area: instrumentation Related to an instrumentation package bug Something isn't working instrumentation: otelhttp

Comments

@VirrageS
Copy link

Description

100 Continue response can be issued many times before an actual response is return (eg. 200 OK). In case of otelhttp these responses should be ignored.

When you look at the http/server.go: https://github.com/golang/go/blob/go1.24.1/src/net/http/server.go#L1212-L1228 you can notice that they only set wroteHeader variable or status when it is not informational header.
But here https://github.com/open-telemetry/opentelemetry-go-contrib/blob/main/instrumentation/net/http/otelhttp/internal/request/resp_writer_wrapper.go#L62-L84 we don't filter 100 Continue response.

Therefore, when 100 Continue is set and then there is no explicit 200 OK reported, then final status code will be 100 and not 200 as it should be.

Environment

  • OS: MacOS
  • Architecture: arch64
  • Go Version: 1.24
  • otelhttp version: v0.56.0

Steps To Reproduce

  1. Use following handler:
    	targetHandler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
    		w.WriteHeader(http.StatusContinue) // Explicitly inform client that we are ready for body.
    		
    		body, _ := io.ReadAll(r.Body)
    		w.Write(body)
    	})
    	http.Handle("/target", otelhttp.NewHandler(targetHandler, "target"))
  2. Run the code.
  3. Handler will report 100 Continue header as final status code instead of 200 OK.

Expected behavior

200 OK status code to be reported even when there is explicit 100 Continue done in the handler.

Likely we need to do similar thing that they do in http/server.go which is to simply ignore informational headers if they are issued before a regular response.

@VirrageS VirrageS added area: instrumentation Related to an instrumentation package bug Something isn't working instrumentation: otelhttp labels Mar 11, 2025
@dmathieu
Copy link
Member

See also #6908 for the same issue in the handler part.

@github-project-automation github-project-automation bot moved this to Needs triage in Go: Triage Apr 10, 2025
@MrAlias MrAlias moved this from Needs triage to Low priority in Go: Triage Apr 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: instrumentation Related to an instrumentation package bug Something isn't working instrumentation: otelhttp
Projects
Status: Low priority
2 participants