Harden URL redaction in transport errors, bound JSONL reads, fix docs#16
Merged
Conversation
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.
Summary
A cross-package pass over the assembled SDK turned up three things worth fixing. No behavioral regressions; all 19 packages stay green under
-race.httperr: stop leaking the raw URL on transport failuresTransportError.URLis redacted, butTransportError.Error()formatted the wrapped cause with%v. When that cause is net/http's*url.Error, its ownError()re-embeds the full, unredacted URL — including query secrets — so logging the error string defeated the redaction everywhere else.Error()now unwraps a*url.Errorand renders its inner cause instead, whileUnwrap()stays lossless soerrors.Is/Asstill reach the original.jsonl: bound the streamDecodewas the one streaming reader in the SDK without a size cap (sse caps lines at 1 MiB, httperr at 8 KiB). Added an opt-inWithMaxBytes(n)that wraps the reader in anio.LimitReader; an oversized value now surfaces a decode error rather than reading unbounded memory. Default behavior is unchanged —Decode(r)callers are unaffected.Docs
client.go, CLAUDE.md) now show the optionalerrorsoutermost stage and use the actualclient-identitystage name; opt-in stages are bracketed.idempotency/.ErrInsecureTransportguard.WithTokenCache,WithBasicAuth,WithAPIKey,WithConfig) no longer sit under Observability.pagination.NewLinkHeaderGoDoc notes the next URL comes from a server-controlledLinkheader.Test plan
go test -race ./...— all 19 packages passgofmt -l .clean,go vet ./...clean,go build ./...cleanTransportError.Error()does not leak a query secret andUnwrapstays lossless;jsonl.WithMaxBytesbounds reads and errors on an oversized value🤖 Generated with Claude Code