Slim AsertoError: single wrapped error, fixed grpc/http correlation, drop dead methods - #21
Merged
Merged
Conversation
…drop dead methods Rebased on top of the concurrent inner-error/formatting fixes (Fields() recursion, Msg-before-cause ordering, errors.As-based traversal) already on main; this does not touch those, it builds on them. Copy() shallow-copied the errs slice, letting siblings derived from the same parent share a backing array and silently corrupt each other's wrapped error once append had slack (azm already hits this pattern via nested Err() calls). Replacing errs []error with a single wrapped error removes the aliasing by construction. Fields()'s recursion into inner AsertoErrors is preserved, adapted to the single wrapped field. GRPCStatus() never wrote HTTPCode into the ErrorInfo metadata that CustomErrorHandler reads back, so the grpc<->HTTP status correlation this package exists for only worked because topaz's gerr_middleware hand-rolled it a second time. Added ErrorInfo()/fixed GRPCStatus() to be the single source of truth. FromGRPCStatus also no longer mutates the registered singleton in place. Removed Int/Int32/Int64/Bool/Duration/Time/FromReader/Interface/SameAs/ Equals/WithGRPCStatus/WithHTTPStatus: zero real call sites across go-directory, topaz, and azm. WithGRPCStatus's one usage in topaz is better served by a dedicated sentinel error than an override. Renamed StatusCode -> GRPCCode for clarity. Downstream repos need updates for the rename and removed methods; DESIGN.md has the full rationale and sequencing. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Signed-off-by: Gert Drapers <1533850+gertd@users.noreply.github.com>
Signed-off-by: Gert Drapers <1533850+gertd@users.noreply.github.com>
Coverage Report for CI Build 32731463535Coverage increased (+4.1%) to 68.465%Details
Uncovered Changes
Coverage Regressions19 previously-covered lines in 1 file lost coverage.
Coverage Stats
💛 - Coveralls |
Signed-off-by: Gert Drapers <1533850+gertd@users.noreply.github.com>
aserto-bot
approved these changes
Aug 24, 2026
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
Copy()shallow-copied theerrs []errorslice, letting siblings derived from the same parent share a backing array and silently corrupt each other's wrapped error onceappendhad slack. Replacederrs []errorwith a singlewrapped errorfield, which removes the aliasing by construction.azmalready hits this pattern via nestedErr()calls, so this isn't theoretical.GRPCStatus()never wroteHTTPCodeinto theerrdetails.ErrorInfometadata thatCustomErrorHandlerreads back, so the one thing this package exists to provide only worked becausetopaz'sgerr_middleware.gohand-rolled it a second time. AddedErrorInfo()and fixedGRPCStatus()to be the single source of truth.FromGRPCStatusno longer mutates the registered singleton*AsertoErrorin place — it copies first.Int/Int32/Int64/Bool/Duration/Time/FromReader/Interface/SameAs/Equals/WithGRPCStatus/WithHTTPStatus— zero real call sites acrossgo-directory,topaz, andazm(verified by cloning and grepping all three).WithGRPCStatus's one usage intopaz(topazd/authorizer/impl/identity.go) is better served by a dedicated sentinel error than an override.StatusCode→GRPCCodefor clarity.This branch was rebased on top of the inner-error/formatting fixes already on
main(Fields()recursion into inner errors,.Msg()-before-cause ordering,errors.As-based traversal) — it builds on those, doesn't touch them.Full design rationale and downstream sequencing notes are in
DESIGN.md.Breaking changes for downstream consumers
topazandazmwill need updates wherever they:.StatusCode(now.GRPCCode).WithGRPCStatus,.WithHTTPStatus,.SameAs, orcerr.Equals.Err()more than once expecting accumulation (each.Err()now replaces rather than appends — only the test suite here exercised that, no downstream repo does)Test plan
go build ./...go vet ./...gofmt -l .cleango test ./... -racepassesCopy()aliasing bug (siblings derived from a 3-deep error chain now stay independent)FromGRPCStatussingleton mutationFields()still recurses into innerAsertoErrors under the new single-wrapped-error model🤖 Generated with Claude Code