Repository navigation
Core module: Return a redirect whose Location header does not parse as the redirect response itself, so a secret in that header stays out of logs - #243
Merged
Conversation
…n header does not parse quotes that header whole, with any secret it holds. Co-Authored-By: Claude <noreply@anthropic.com>
…rse as a URL, so the configured HTTP client returns the response itself where it failed with an error that quoted the header. Co-Authored-By: Claude <noreply@anthropic.com>
QuintinWillison
marked this pull request as ready for review
November 30, 2026 13:03
Base automatically changed from
postgrest-server-counts-writes-to-table-named-rpc
to
main
December 2, 2026 11:03
QuintinWillison
deleted the
core-redirect-location-stays-out-of-errors
branch
December 2, 2026 11:03
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 Claude's Summary
When a redirect's
Locationheader does not parse as a URL, Go'shttp.Clientfails the request with an error whose text quotes the header twice (client.go). The client thatConfiguration.HTTPClientreturns passed that text on. ALocationcan hold a secret, such as the access token in the redirect that ends a sign-in, so a program that logged the error wrote that secret to its log.The SDK's transport now removes a
Locationheader that does not parse from a redirect response, of any 3xx status. Go's client returns a redirect that has noLocationheader as the response itself (Go 1.19 release notes), so the request no longer fails, and a domain client reports the redirect as it reports any other non-2xx response. That is how the SDK has answered a redirect to another origin since #227. A read no longer retries such a redirect.The other repair would be to rewrite the error. Go gives that error no type of its own, so only its English wording could identify it, and Go does not promise to keep an error's wording: Go 1.14 reworded part of this one. Removing the header depends on no text. The check for a header that does not parse is
url.Parse, which is the check Go's client makes.HTTPClient's doc comment gains the new case beside the two it already lists for a redirect. Its sentence on a failedDo, from #232, now says that the error's URL leaves out the query string and user information. It said that of the error's whole text, which the SDK does not control, since the cause is Go's or the transport's own.The first commit pins the defect with a test that passes against it. Its second case, a response of another status that carries the same header, keeps the header before the fix and after it. The fix follows and flips the redirect case. No service in the local stack sends a
Locationthat does not parse, so the test uses a local server and has no integration test beside it.