Repository navigation
feat(server): RFC 9457 problem details and a stable error-code registry - #825
Conversation
866363a to
efcf93d
Compare
jhrozek
left a comment
There was a problem hiding this comment.
Reviewed with three parallel specialist passes (security on the secret-guard scope, duplication-elimination check on the chain consolidation, gRPC ErrorInfo wiring/casing). The consolidation itself is clean — genuine single source of truth, no residual duplication, real byte-identical codes across transports (verified by a proper test oracle, not two constants that happen to match), and this closes exactly what was recommended on #822 for the gRPC error mechanism. Four comments below, nothing blocking — approving.
|
|
||
| all := append(append([]errorCodeEntry{}, errorRegistry...), genericErrorEntry) | ||
| for _, e := range all { | ||
| doc := newProblem(e, "detail text") |
There was a problem hiding this comment.
This test checks code/title/type for secret-shaped content on every registry row, but always passes a fixed, harmless "detail text" literal — it never verifies detail/error (which carry the caller's real err.Error(), only UTF-8-repaired and length-clamped, no content scrubbing). Not a regression from this PR — writeError already passed err.Error() straight through before this, and today's known risky backends (migration/cleanup/storage-health) sanitize at their own boundary — but the PR's AC2.4 language ("no problem body carries a secret... across every registered code's rendered output") reads as a stronger guarantee than what's actually tested. Worth either narrowing that claim's wording, or extending this test to also probe detail with a secret-shaped value.
There was a problem hiding this comment.
Good catch, and I took the "narrow the claim" half as well as the test half, because they were disagreeing about different things.
AC2.4's wording is narrowed on the ADR commit to say the guard covers the harness-authored halves only. And TestADR_0244_DetailIsPassedThroughNotScrubbed now asserts the pass-through explicitly with secret-shaped values, so the boundary is a decision on the record rather than an untested assumption — and a future author adding scrubbing has to come delete an assertion that explains why it wasn't wanted.
The reason it stays unscrubbed is in the test comment: a denylist over free-text error prose is the same false-positive generator the existing comment already describes for titles, and this layer doesn't know which substring is sensitive — only the backend that raised the error does. Redacting there is precise; redacting here is a guess that corrupts diagnostics.
| // BOTH. If the registry were a map (or if someone reordered it), this would | ||
| // classify as the general precondition failure and the HTTP status would change | ||
| // from 409 to 412 — a silently different contract for a client branching on it. | ||
| func TestSDKServerEnablers_Scenario2_SpecificSentinelsWinOverGeneral(t *testing.T) { |
There was a problem hiding this comment.
This protects the one known wrapping pair (ErrFailedStepRetryIneligible/ErrFailedPrecondition) by name. There's no generic/structural check that would catch a future wrapping pair inserted in the wrong order in errorRegistry — correctness for any new pair depends on the next author remembering to hand-write another test like this one. Not asking for a fix now, just flagging so it doesn't get forgotten as the registry grows.
There was a problem hiding this comment.
Not forgotten — fixed generically in feb83b5. TestADR_0244_NoRegistryRowIsShadowed walks errorRegistry itself and asserts each row's own sentinel resolves back to that row, so a future pair in the wrong order fails with no test edit. Mutation-verified by swapping the two real rows: registry row 25 ("failed_step_retry_ineligible") is SHADOWED.
Worth flagging what writing it turned up, though. The obvious spelling of that assertion is errors.Is, and errors.Is is vacuous here — a specific sentinel wraps the general one, so errors.Is(specific, general) is true whether the row resolved correctly or was shadowed by the very row it wraps. It passes in exactly the case it's checking. Only pointer identity separates them.
That matters beyond the new test: #828 replaced this PR's count-equality with a shadow check spelled with errors.Is, which had the same hole. Fixed there too in 1680c9a, so the golden-table check now compares by identity.
| @@ -1475,131 +1476,39 @@ func toProtoCleanupJob(job CleanupJob) *mecatlv1.CleanupJob { | |||
| // | |||
| //nolint:gocyclo // a flat error→code classifier; a switch is the correct shape. | |||
There was a problem hiding this comment.
Stale — this justified the old 49-case switch, which is now a one-line delegation to classifyError. Safe to drop.
| func statusForEntry(entry errorCodeEntry, err error) error { | ||
| st := status.New(entry.GRPC, session.ToValidUTF8(err.Error())) | ||
| withDetail, derr := st.WithDetails(&errdetails.ErrorInfo{ | ||
| Reason: entry.Code, |
There was a problem hiding this comment.
Nice — this is exactly what was suggested on #822 (use google.rpc.ErrorInfo instead of a mecatl-authored detail message), and Reason is genuinely the same lowercase code as the HTTP side rather than converted to the AIP-193-conventional UPPER_SNAKE_CASE, verified byte-for-byte by TestSDKServerEnablers_Scenario2_ErrorCodeTransportParity. Worth one line of comment here saying that's deliberate (parity across transports beats the casing convention) so a future reader doesn't "fix" the casing and silently reintroduce the divergence #822's comment was worried about.
There was a problem hiding this comment.
Added. The comment names the trade (AC2.2's identical-string requirement beats the AIP-193 convention, and the HTTP side is lowercase to match RFC 9457 style) and points at TestSDKServerEnablers_Scenario2_ErrorCodeTransportParity as the thing that fails if it's undone. ADR 0244 decision 7 now records it too, so it's discoverable from either end.
Three fixes from the #825 review, plus one thing found while making them. STALE COMMENT. toStatus carried a //nolint:gocyclo justifying "a flat error→code classifier; a switch is the correct shape". The 49-case switch it described is gone — the body is now a one-line delegation to classifyError. Dropped. THE CASING CHOICE IS NOW ON THE RECORD AT THE SITE. ErrorInfo.Reason carries the code in lower_snake_case, against AIP-193's UPPER_SNAKE_CASE convention, because AC2.2 requires the identical string on both transports and the HTTP side is lowercase to match RFC 9457 style. That was a deliberate trade with nothing at the code to say so, and a future reader "fixing" the casing would silently reintroduce exactly the divergence #822 raised the concern about. The comment names the trade and points at the parity test that fails if it is undone. A GENERIC NO-SHADOWING GATE. SpecificSentinelsWinOverGeneral protects the one known wrapping pair BY NAME, so any future pair depends on the next author remembering to hand-write another test. TestADR_0244_NoRegistryRowIsShadowed walks the registry itself and asserts every row's own sentinel resolves back to that row, so a mis-ordered pair fails with no test edit. Mutation-verified: swapping the two real rows produces "registry row 25 (failed_step_retry_ineligible) is SHADOWED". It asserts row IDENTITY, and that is the part worth reading twice. The obvious spelling is errors.Is — and errors.Is is VACUOUS here. A specific sentinel wraps the general one, so errors.Is(specific, general) is true, which means an errors.Is assertion holds both when the row resolves correctly and when it has been shadowed by the very row it wraps. It would pass in precisely the case it exists to catch. Only pointer identity separates them. The test carries its own bite check against a deliberately mis-ordered table so it cannot rot into theatre. AC2.4's SCOPE IS NOW TESTED, NOT ASSUMED. The no-secret walk covers code, title, and type — the halves mecatl authors — but the AC claimed "no problem body carries a secret", which reads as covering detail/error too. Those carry the caller's err.Error(), bounded and UTF-8-repaired but not scrubbed. Rather than weaken the test to match the words or strengthen the code to match the claim, the pass-through is now asserted explicitly, with the reason: a denylist over free-text error prose is the same false-positive generator the existing comment describes for titles, and this layer does not know which substring is sensitive — only the backend that raised the error does, which is where today's risky ones already sanitize. A future author adding scrubbing now has to delete an assertion that explains why it was not wanted. (The AC wording itself is narrowed in the plan doc, on the ADR commit.) Gates: go test green on internal/adapter/server; gofmt clean. Refs #821. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Signed-off-by: Samuele Verzi <[email protected]>
efcf93d to
feb83b5
Compare
Three fixes from the #825 review, plus one thing found while making them. STALE COMMENT. toStatus carried a //nolint:gocyclo justifying "a flat error→code classifier; a switch is the correct shape". The 49-case switch it described is gone — the body is now a one-line delegation to classifyError. Dropped. THE CASING CHOICE IS NOW ON THE RECORD AT THE SITE. ErrorInfo.Reason carries the code in lower_snake_case, against AIP-193's UPPER_SNAKE_CASE convention, because AC2.2 requires the identical string on both transports and the HTTP side is lowercase to match RFC 9457 style. That was a deliberate trade with nothing at the code to say so, and a future reader "fixing" the casing would silently reintroduce exactly the divergence #822 raised the concern about. The comment names the trade and points at the parity test that fails if it is undone. A GENERIC NO-SHADOWING GATE. SpecificSentinelsWinOverGeneral protects the one known wrapping pair BY NAME, so any future pair depends on the next author remembering to hand-write another test. TestADR_0244_NoRegistryRowIsShadowed walks the registry itself and asserts every row's own sentinel resolves back to that row, so a mis-ordered pair fails with no test edit. Mutation-verified: swapping the two real rows produces "registry row 25 (failed_step_retry_ineligible) is SHADOWED". It asserts row IDENTITY, and that is the part worth reading twice. The obvious spelling is errors.Is — and errors.Is is VACUOUS here. A specific sentinel wraps the general one, so errors.Is(specific, general) is true, which means an errors.Is assertion holds both when the row resolves correctly and when it has been shadowed by the very row it wraps. It would pass in precisely the case it exists to catch. Only pointer identity separates them. The test carries its own bite check against a deliberately mis-ordered table so it cannot rot into theatre. AC2.4's SCOPE IS NOW TESTED, NOT ASSUMED. The no-secret walk covers code, title, and type — the halves mecatl authors — but the AC claimed "no problem body carries a secret", which reads as covering detail/error too. Those carry the caller's err.Error(), bounded and UTF-8-repaired but not scrubbed. Rather than weaken the test to match the words or strengthen the code to match the claim, the pass-through is now asserted explicitly, with the reason: a denylist over free-text error prose is the same false-positive generator the existing comment describes for titles, and this layer does not know which substring is sensitive — only the backend that raised the error does, which is where today's risky ones already sanitize. A future author adding scrubbing now has to delete an assertion that explains why it was not wanted. (The AC wording itself is narrowed in the plan doc, on the ADR commit.) Gates: go test green on internal/adapter/server; gofmt clean. Refs #821. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Signed-off-by: Samuele Verzi <[email protected]>
feb83b5 to
59d2fa9
Compare
Three fixes from the #825 review, plus one thing found while making them. STALE COMMENT. toStatus carried a //nolint:gocyclo justifying "a flat error→code classifier; a switch is the correct shape". The 49-case switch it described is gone — the body is now a one-line delegation to classifyError. Dropped. THE CASING CHOICE IS NOW ON THE RECORD AT THE SITE. ErrorInfo.Reason carries the code in lower_snake_case, against AIP-193's UPPER_SNAKE_CASE convention, because AC2.2 requires the identical string on both transports and the HTTP side is lowercase to match RFC 9457 style. That was a deliberate trade with nothing at the code to say so, and a future reader "fixing" the casing would silently reintroduce exactly the divergence #822 raised the concern about. The comment names the trade and points at the parity test that fails if it is undone. A GENERIC NO-SHADOWING GATE. SpecificSentinelsWinOverGeneral protects the one known wrapping pair BY NAME, so any future pair depends on the next author remembering to hand-write another test. TestADR_0244_NoRegistryRowIsShadowed walks the registry itself and asserts every row's own sentinel resolves back to that row, so a mis-ordered pair fails with no test edit. Mutation-verified: swapping the two real rows produces "registry row 25 (failed_step_retry_ineligible) is SHADOWED". It asserts row IDENTITY, and that is the part worth reading twice. The obvious spelling is errors.Is — and errors.Is is VACUOUS here. A specific sentinel wraps the general one, so errors.Is(specific, general) is true, which means an errors.Is assertion holds both when the row resolves correctly and when it has been shadowed by the very row it wraps. It would pass in precisely the case it exists to catch. Only pointer identity separates them. The test carries its own bite check against a deliberately mis-ordered table so it cannot rot into theatre. AC2.4's SCOPE IS NOW TESTED, NOT ASSUMED. The no-secret walk covers code, title, and type — the halves mecatl authors — but the AC claimed "no problem body carries a secret", which reads as covering detail/error too. Those carry the caller's err.Error(), bounded and UTF-8-repaired but not scrubbed. Rather than weaken the test to match the words or strengthen the code to match the claim, the pass-through is now asserted explicitly, with the reason: a denylist over free-text error prose is the same false-positive generator the existing comment describes for titles, and this layer does not know which substring is sensitive — only the backend that raised the error does, which is where today's risky ones already sanitize. A future author adding scrubbing now has to delete an assertion that explains why it was not wanted. (The AC wording itself is narrowed in the plan doc, on the ADR commit.) Gates: go test green on internal/adapter/server; gofmt clean. Refs #821. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Signed-off-by: Samuele Verzi <[email protected]>
59d2fa9 to
469f4cf
Compare
469f4cf to
e8afa3d
Compare
Three fixes from the #825 review, plus one thing found while making them. STALE COMMENT. toStatus carried a //nolint:gocyclo justifying "a flat error→code classifier; a switch is the correct shape". The 49-case switch it described is gone — the body is now a one-line delegation to classifyError. Dropped. THE CASING CHOICE IS NOW ON THE RECORD AT THE SITE. ErrorInfo.Reason carries the code in lower_snake_case, against AIP-193's UPPER_SNAKE_CASE convention, because AC2.2 requires the identical string on both transports and the HTTP side is lowercase to match RFC 9457 style. That was a deliberate trade with nothing at the code to say so, and a future reader "fixing" the casing would silently reintroduce exactly the divergence #822 raised the concern about. The comment names the trade and points at the parity test that fails if it is undone. A GENERIC NO-SHADOWING GATE. SpecificSentinelsWinOverGeneral protects the one known wrapping pair BY NAME, so any future pair depends on the next author remembering to hand-write another test. TestADR_0244_NoRegistryRowIsShadowed walks the registry itself and asserts every row's own sentinel resolves back to that row, so a mis-ordered pair fails with no test edit. Mutation-verified: swapping the two real rows produces "registry row 25 (failed_step_retry_ineligible) is SHADOWED". It asserts row IDENTITY, and that is the part worth reading twice. The obvious spelling is errors.Is — and errors.Is is VACUOUS here. A specific sentinel wraps the general one, so errors.Is(specific, general) is true, which means an errors.Is assertion holds both when the row resolves correctly and when it has been shadowed by the very row it wraps. It would pass in precisely the case it exists to catch. Only pointer identity separates them. The test carries its own bite check against a deliberately mis-ordered table so it cannot rot into theatre. AC2.4's SCOPE IS NOW TESTED, NOT ASSUMED. The no-secret walk covers code, title, and type — the halves mecatl authors — but the AC claimed "no problem body carries a secret", which reads as covering detail/error too. Those carry the caller's err.Error(), bounded and UTF-8-repaired but not scrubbed. Rather than weaken the test to match the words or strengthen the code to match the claim, the pass-through is now asserted explicitly, with the reason: a denylist over free-text error prose is the same false-positive generator the existing comment describes for titles, and this layer does not know which substring is sensitive — only the backend that raised the error does, which is where today's risky ones already sanitize. A future author adding scrubbing now has to delete an assertion that explains why it was not wanted. (The AC wording itself is narrowed in the plan doc, on the ADR commit.) Gates: go test green on internal/adapter/server; gofmt clean. Refs #821. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Signed-off-by: Samuele Verzi <[email protected]>
e8afa3d to
ba2f760
Compare
Three fixes from the #825 review, plus one thing found while making them. STALE COMMENT. toStatus carried a //nolint:gocyclo justifying "a flat error→code classifier; a switch is the correct shape". The 49-case switch it described is gone — the body is now a one-line delegation to classifyError. Dropped. THE CASING CHOICE IS NOW ON THE RECORD AT THE SITE. ErrorInfo.Reason carries the code in lower_snake_case, against AIP-193's UPPER_SNAKE_CASE convention, because AC2.2 requires the identical string on both transports and the HTTP side is lowercase to match RFC 9457 style. That was a deliberate trade with nothing at the code to say so, and a future reader "fixing" the casing would silently reintroduce exactly the divergence #822 raised the concern about. The comment names the trade and points at the parity test that fails if it is undone. A GENERIC NO-SHADOWING GATE. SpecificSentinelsWinOverGeneral protects the one known wrapping pair BY NAME, so any future pair depends on the next author remembering to hand-write another test. TestADR_0244_NoRegistryRowIsShadowed walks the registry itself and asserts every row's own sentinel resolves back to that row, so a mis-ordered pair fails with no test edit. Mutation-verified: swapping the two real rows produces "registry row 25 (failed_step_retry_ineligible) is SHADOWED". It asserts row IDENTITY, and that is the part worth reading twice. The obvious spelling is errors.Is — and errors.Is is VACUOUS here. A specific sentinel wraps the general one, so errors.Is(specific, general) is true, which means an errors.Is assertion holds both when the row resolves correctly and when it has been shadowed by the very row it wraps. It would pass in precisely the case it exists to catch. Only pointer identity separates them. The test carries its own bite check against a deliberately mis-ordered table so it cannot rot into theatre. AC2.4's SCOPE IS NOW TESTED, NOT ASSUMED. The no-secret walk covers code, title, and type — the halves mecatl authors — but the AC claimed "no problem body carries a secret", which reads as covering detail/error too. Those carry the caller's err.Error(), bounded and UTF-8-repaired but not scrubbed. Rather than weaken the test to match the words or strengthen the code to match the claim, the pass-through is now asserted explicitly, with the reason: a denylist over free-text error prose is the same false-positive generator the existing comment describes for titles, and this layer does not know which substring is sensitive — only the backend that raised the error does, which is where today's risky ones already sanitize. A future author adding scrubbing now has to delete an assertion that explains why it was not wanted. (The AC wording itself is narrowed in the plan doc, on the ADR commit.) Gates: go test green on internal/adapter/server; gofmt clean. Refs #821. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Signed-off-by: Samuele Verzi <[email protected]>
ba2f760 to
dca21e8
Compare
PR 2 of the #821 server-enabler stack. Implements Scenario 2 of docs/acceptance/sdk-server-enablers.md (AC2.1-AC2.6) per ADR 0243. HTTP errors were untyped prose: one writeError emitting {"error": "<msg>"}. A client could read a status and a human string but could not branch on a stable machine identifier. gRPC callers got a codes.Code, which is far coarser than the domain — a dozen distinct conditions collapse onto FailedPrecondition — so the two transports disagreed about what went wrong. That is fatal for an SDK whose premise is one normalized error surface. The structural change is collapsing TWO hand-maintained classifiers into one registry. toStatus (grpc.go) and writeServiceError (http.go) were 49-case errors.Is chains that had to agree by discipline alone. They did agree — I verified all 45 shared sentinels before touching them — but nothing enforced it, and a sentinel added to one and forgotten in the other would silently report a different class per transport. Both are now one-line registry lookups. ORDER IS LOAD-BEARING and the registry is a SLICE, not a map: sentinels wrap other sentinels (ErrFailedStepRetryIneligible wraps ErrFailedPrecondition), so errors.Is matches both and the specific row must come first. A map would randomise iteration and silently reclassify. Pinned by TestSDKServerEnablers_Scenario2_SpecificSentinelsWinOverGeneral. The behaviour-preservation proof is a golden table extracted mechanically from the PRE-refactor source, not retyped. It earned its place immediately: the first mechanical extraction silently dropped four port.*-qualified cases (ErrSessionMetadataCursorRestart, ErrSessionMetadataPagingUnsupported, ErrScheduleNotFound, ErrScheduleUnsupported) because the pattern only matched unqualified Err* identifiers. The compiler caught that one; the table is what catches the next. Codes are open strings, not a proto enum — same discipline as `features` in PR 1. RFC 9457 `type` is a URN (urn:mecatl:error:<code>) rather than an https:// URL, because publishing a URL we do not serve is worse documentation than one that never claimed to be fetchable; the bare code also travels in a `code` extension so clients branch on a string, not a URI parse. gRPC carries the same identifier as a google.rpc.ErrorInfo detail (Reason=code, Domain=mecatl.stacklok.com). Attaching it is best-effort: a marshal failure degrades to the bare status rather than losing the error. `detail` is UTF-8-repaired and bounded to 2048 bytes, cutting on a rune boundary — a truncated multi-byte rune is itself invalid UTF-8, re-creating the marshal-killing fault the repair exists to prevent. The `error` compatibility key carries the same repaired text, so old and new clients never see different messages. AC2.4's no-secret guard checks the two halves DIFFERENTLY on purpose. `code` is a machine vocabulary we author, so a bare-word denylist is exact there. `title` is English prose, and a word denylist on prose is a false-positive generator — the first run failed on "Management authorization required", which leaks nothing. The title half therefore checks value SHAPES (bearer forms, key=value, unbroken opaque runs), and the matcher itself is tested against both leaks it must catch and prose it must not, so it cannot be quietly defanged. Blast radius: only ERROR bodies moved to application/problem+json; success responses stay application/json (pinned). There are no in-repo non-test HTTP consumers — mecatui is a gRPC client. Gates: task lint 0 issues across all modules; Scenario 2 tests green. go.mod: genproto/googleapis/rpc promoted indirect -> direct (no version change) for errdetails. Refs #821. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Signed-off-by: Samuele Verzi <[email protected]>
Three fixes from the #825 review, plus one thing found while making them. STALE COMMENT. toStatus carried a //nolint:gocyclo justifying "a flat error→code classifier; a switch is the correct shape". The 49-case switch it described is gone — the body is now a one-line delegation to classifyError. Dropped. THE CASING CHOICE IS NOW ON THE RECORD AT THE SITE. ErrorInfo.Reason carries the code in lower_snake_case, against AIP-193's UPPER_SNAKE_CASE convention, because AC2.2 requires the identical string on both transports and the HTTP side is lowercase to match RFC 9457 style. That was a deliberate trade with nothing at the code to say so, and a future reader "fixing" the casing would silently reintroduce exactly the divergence #822 raised the concern about. The comment names the trade and points at the parity test that fails if it is undone. A GENERIC NO-SHADOWING GATE. SpecificSentinelsWinOverGeneral protects the one known wrapping pair BY NAME, so any future pair depends on the next author remembering to hand-write another test. TestADR_0244_NoRegistryRowIsShadowed walks the registry itself and asserts every row's own sentinel resolves back to that row, so a mis-ordered pair fails with no test edit. Mutation-verified: swapping the two real rows produces "registry row 25 (failed_step_retry_ineligible) is SHADOWED". It asserts row IDENTITY, and that is the part worth reading twice. The obvious spelling is errors.Is — and errors.Is is VACUOUS here. A specific sentinel wraps the general one, so errors.Is(specific, general) is true, which means an errors.Is assertion holds both when the row resolves correctly and when it has been shadowed by the very row it wraps. It would pass in precisely the case it exists to catch. Only pointer identity separates them. The test carries its own bite check against a deliberately mis-ordered table so it cannot rot into theatre. AC2.4's SCOPE IS NOW TESTED, NOT ASSUMED. The no-secret walk covers code, title, and type — the halves mecatl authors — but the AC claimed "no problem body carries a secret", which reads as covering detail/error too. Those carry the caller's err.Error(), bounded and UTF-8-repaired but not scrubbed. Rather than weaken the test to match the words or strengthen the code to match the claim, the pass-through is now asserted explicitly, with the reason: a denylist over free-text error prose is the same false-positive generator the existing comment describes for titles, and this layer does not know which substring is sensitive — only the backend that raised the error does, which is where today's risky ones already sanitize. A future author adding scrubbing now has to delete an assertion that explains why it was not wanted. (The AC wording itself is narrowed in the plan doc, on the ADR commit.) Gates: go test green on internal/adapter/server; gofmt clean. Refs #821. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Signed-off-by: Samuele Verzi <[email protected]>
dca21e8 to
dcbd311
Compare
What
PR 2 of 9 in the #821 server-enabler stack. Implements Scenario 2 of
docs/acceptance/sdk-server-enablers.md— AC2.1–AC2.6 — per ADR 0244.RFC 9457
application/problem+jsonon HTTP,google.rpc.ErrorInfodetails on gRPC, and one stable error-code registry feeding both.Why
HTTP errors were untyped prose — a single
writeErroremitting{"error": "<msg>"}. A client could read a status and a human string but could not branch on a stable machine identifier. gRPC callers got acodes.Code, which is far coarser than the domain (a dozen distinct conditions collapse ontoFailedPrecondition). The two transports therefore disagreed about what went wrong — fatal for an SDK whose premise is one normalized error surface (#821 AC3).The structural change
toStatus(grpc.go) andwriteServiceError(http.go) were two hand-maintained 49-caseerrors.Ischains that had to agree by discipline alone. They did agree — I verified all 45 shared sentinels before touching them — but nothing enforced it, and a sentinel added to one and forgotten in the other would silently report a different class per transport.Both are now one-line registry lookups.
Order is load-bearing, and the registry is a slice, not a map. Sentinels wrap other sentinels (
ErrFailedStepRetryIneligiblewrapsErrFailedPrecondition), soerrors.Ismatches both and the specific row must come first. A map would randomise iteration and silently reclassify — turning a 409 into a 412 for anyone branching on it. Pinned byTestSDKServerEnablers_Scenario2_SpecificSentinelsWinOverGeneral.The golden table earned its place immediately
The behaviour-preservation proof is a table extracted mechanically from the pre-refactor source, not retyped. My first mechanical extraction silently dropped four
port.*-qualified cases —ErrSessionMetadataCursorRestart,ErrSessionMetadataPagingUnsupported,ErrScheduleNotFound,ErrScheduleUnsupported— because the pattern only matched unqualifiedErr*identifiers. The compiler caught that one (an import went unused). The table is what catches the next.Notable choices
featuresin PR 1.typeis a URN (urn:mecatl:error:<code>), not anhttps://URL. Publishing a URL we don't serve is worse documentation than one that never claimed to be fetchable. The bare code also rides acodeextension so clients branch on a string, not a URI parse.google.rpc.ErrorInfo(Reason=code,Domain=mecatl.stacklok.com). Attaching it is best-effort: a marshal failure degrades to the bare status rather than losing the error.detailis UTF-8-repaired and bounded to 2048 bytes, cutting on a rune boundary — a truncated multi-byte rune is itself invalid UTF-8, re-creating the marshal-killing fault the repair exists to prevent. Theerrorcompatibility key carries the same repaired text, so old and new clients never see different messages.instanceis omitted, not fabricated — mecatl has no request-id concept, and a field that correlates to nothing is worse than an absent one.The AC2.4 secret guard checks two halves differently — on purpose
codeis a machine vocabulary we author, so a bare-word denylist is exact there.titleis English prose, and a word denylist on prose is a false-positive generator: the first run failed on"Management authorization required", which leaks nothing. So the title half checks value shapes (bearer forms,key=value, unbroken opaque runs) instead of vocabulary.The matcher is itself tested — against leaks it must catch and prose it must not — so it can't be quietly defanged by the next person who trips it. (Its "opaque run" class also had to exclude
_/-: those are word separators in our own vocabulary, and including them matched long snake_case codes.)Blast radius
Only error bodies moved to
application/problem+json; success responses stayapplication/json(pinned byTestSDKServerEnablers_Scenario2_SuccessResponsesAreUnchanged). There are no in-repo non-test HTTP consumers —mecatuiis a gRPC client.Acceptance criteria
errorcompat keyTestSDKServerEnablers_Scenario2_ProblemJSONShapeTestSDKServerEnablers_Scenario2_ErrorCodeTransportParityTestADR_0244_ErrorRegistryIsTotalAndUnambiguousTestADR_0244_ProblemDetailsCarryNoSecretsTestSDKServerEnablers_Scenario2_UnregisteredFailureDegradesTestSDKServerEnablers_Scenario2_DetailIsBoundedAndValidUTF8TestSDKServerEnablers_Scenario2_RegistryPreservesPreRefactorMappingsVerification
task lint0 issues across all modules.go test -race ./...green on root and engine, all four provider modules, both standalone hygiene proofs, andmecademo.go.mod:genproto/googleapis/rpcpromoted indirect → direct (no version change) forerrdetails.mainfound while running the gatestask testfails on macOS —#786's new jsonlstore durability check rejectsTMPDIRbecause macOS puts it under/var, a symlink to/private/var:jsonlstore: create store dir: path "/var" is not a directory. Reproduced on a cleanorigin/mainworktree; passes with a resolvedTMPDIR. CI is Linux so it stays green there, but it breaks the suite on every macOS dev machine.test:authn-standaloneandtask tidyboth fail —authn/oidc/fixture_test.go:12importsinternal/adapter/server, breaking theGOWORK=offstandalone hygiene proof. Also onorigin/main.Neither is addressed here; folding them in would hide them.
Refs #821.
🤖 Generated with Claude Code