Skip to content
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

http: superfluous response.WriteHeader #487

Closed
cachalots opened this issue Oct 13, 2023 · 3 comments · Fixed by #515
Closed

http: superfluous response.WriteHeader #487

cachalots opened this issue Oct 13, 2023 · 3 comments · Fixed by #515
Assignees
Labels
dif/medium Prior experience is likely helpful effort/hours Estimated to take one or several hours kind/bug A bug in existing code (including security flaws) need/analysis Needs further analysis before proceeding P1 High: Likely tackled by core team if no one steps up

Comments

@cachalots
Copy link

There are many error logs in the IPFS gateway.

http: superfluous response.WriteHeader call from github.com/ipfs/boxo/gateway.webError (errors.go:175)

http: superfluous response.WriteHeader call from github.com/ipfs/boxo/gateway.webError (errors.go:165)

Calling writeError after writeHeader will trigger this error. I'm not sure if this part of the code is causing it, but this code will trigger this issue.

boxo/gateway/handler.go

Lines 921 to 928 in 6602207

w.WriteHeader(http.StatusBadRequest)
if err := redirectTemplate.Execute(w, redirectTemplateData{
RedirectURL: intendedURL,
SuggestedPath: intendedPath.String(),
ErrorMsg: fmt.Sprintf("invalid path: %q should be %q", r.URL.Path, intendedPath.String()),
}); err != nil {
i.webError(w, r, fmt.Errorf("failed to redirect when fixing superfluous namespace: %w", err), http.StatusBadRequest)
}

@cachalots cachalots added the need/triage Needs initial labeling and prioritization label Oct 13, 2023
@welcome

This comment was marked as resolved.

@lidel
Copy link
Member

lidel commented Oct 30, 2023

@cachalots

  • how are you using boxo/gateway? as a library in you app?
  • do you have more than a single mux / listener / instance of gateway?

Mind providing the smallest demo.go that reproduces the issue?

@lidel lidel added the need/author-input Needs input from the original author label Oct 30, 2023
@lidel lidel removed their assignment Oct 30, 2023
@cachalots
Copy link
Author

@lidel https://github.com/4everland/ipfs-servers/blob/dev/app/gateway/internal/server/http.go
Same usage as in example, only replacing the implementation of blockstore.
In theory, if there are enough requests, the gateway example should also reproduce this error. This error was reported by net/http, so it's not easy to assert which location triggered this error.

@lidel lidel added P1 High: Likely tackled by core team if no one steps up dif/medium Prior experience is likely helpful effort/hours Estimated to take one or several hours kind/bug A bug in existing code (including security flaws) need/analysis Needs further analysis before proceeding and removed need/author-input Needs input from the original author need/triage Needs initial labeling and prioritization labels Nov 20, 2023
lidel pushed a commit that referenced this issue Nov 22, 2023
* fix(gateway): do not act on template errors
* docs: changelog
* feat: write error on template execution error

Closes #487
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dif/medium Prior experience is likely helpful effort/hours Estimated to take one or several hours kind/bug A bug in existing code (including security flaws) need/analysis Needs further analysis before proceeding P1 High: Likely tackled by core team if no one steps up
Projects
No open projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants