Repository navigation
feat(api)!: answer like api.New on the default instance - #71
Merged
Merged
Conversation
Owner decision (2026-11-21): in v1.0.0 the default instance (requests without an api.New instance in context) behaves like api.New() with its defaults. This change covers the wire behavior; logging follows in the next change of the stack. The fromNew forks for codes, token echo, RequestHeaderSession, the body limit and problem mode are gone; one code path serves both. ADR 0001 gets Amendment 1; README and the migration guide make "what changes without code changes" the main upgrade path. BREAKING CHANGE: for programs that use the package-level API without api.New (the default instance): - response codes are sent as declared (E001, E300, TSK-001), not lowercased; there is no package-level switch back, only api.New(api.WithLowercaseCodes()); - the request token (SecurityToken header, Authorization: Bearer, envelope header.token) is no longer echoed in response bodies; - RequestHeaderSession no longer copies the SecurityToken request header into the response header; - ProcessRequest, RequestBody, ProcessBody, ProcessEncryptedBody and UnmarshalBody read at most 10 MiB; a larger body, or any *http.MaxBytesError, answers 413 E002 "Request content too large" (v0.11.0: no limit, 400 for a service-installed limit); - SetResponseMode(ResponseModeProblem) is accepted and writes RFC 9457 problem details (v0.11.0 fell back to envelope); - the zero ResponseFormatter sends codes as declared. Stay on v0.11.x to keep v0 behavior. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Scope
PR 1 of 2 (stack: this PR → master; PR 2
feat/default-instance-slogtargets this branch). Owner decision 2026-11-21: in v1.0.0 the default instance (requests without anapi.Newinstance in the context) behaves likeapi.New()with its defaults.This PR: the wire behavior of the default instance. Logging through
slog.Defaultis PR 2. No tag; merge bottom-up (this one first, then retarget PR 2 tomaster).Reason for the split: the full change is ~1,760 changed lines (PR-02 limit 1,000). Each PR passes gofmt, vet,
-raceand govulncheck on its own base.Changes
fromNewforks for codes, token echo,RequestHeaderSession, the body limit and problem mode are removed.getSecurityTokenis deleted.ResponseFormattersends codes as declared (declaredCodes→lowercaseCodes).WithLowercaseCodesis the only way back.Success/Error/Warning/Informative.Writeno longer fillSecurityTokenfrom the request.RequestHeaderSessionno longer copies the header.ProcessRequest,RequestBody,ProcessBody,ProcessEncryptedBody,UnmarshalBody). Any*http.MaxBytesErroranswers 413E002. A handler that readsr.Bodyitself is not bounded outside an instance.SetResponseMode(ResponseModeProblem)is accepted.docs/legacy.mdupdated.Breaking (default-instance users)
E001,TSK-001).RequestHeaderSessionheader.SetResponseMode(ResponseModeProblem)now writes problem details.Stay on v0.11.x to keep v0 behavior.
Tests
default_instance_test.go:TestDefaultInstanceAnswersLikeNew: status, headers and body equalNew().Handler, apart from event IDs (14 cases);TestInstanceLimitAboveTheDefaultIsNotCapped(a largerWithMaxBodyBytesis not capped at 10 MiB).Verification
gofmt -l .: empty.go vet ./...: OK.go test -race ./...: all packages OK.govulncheck ./...: no vulnerabilities.Decisions and open owner questions: questions-for-owner, "Default instance = New (2026-11-21)", Q52 and Q53.
🤖 Generated with Claude Code