Retry: hand out a copy of the declared status set, and run the parity guard in CI
Two tails from #486. It merged with nine of ten review threads unresolved; an audit of all of them found exactly two real defects, and these are they. Neither is user-visible today.
1. GetOperationRetryOn handed out the shared table
go/pkg/generated/client.gen.go returned the slice stored in the package-level operationRetryOn map, and isRetryableStatus reads that same table on every response. Any caller who inspected the declared set could rewrite the retry policy for every client in the process, and race with in-flight requests while doing it.
Reproduced from an external module before fixing — an always-429 server:
before mutation: server saw 3 requests
after set[0], set[1] = 599, 599
after mutation: server saw 1 requests
It is the only exported accessor in the generated package that returns a reference type from a package-level table — GetOperationRetryMax returns an int, GetOperationMetadata a struct of two bools. Confirmed by sweeping for exported funcs returning slices or maps: one hit.
Fixed in go/templates/client.tmpl and regenerated. append([]int(nil), r...) rather than slices.Clone because the generated import block comes from oapi-codegen's base template and this needs no new import. The early return keeps ok — not nilness — as the signal separating a declared-empty set from an absent one, which is what isRetryableStatus depends on.
The regression test is a real red proof. Against the unfixed accessor it fails with:
accessor leaked the shared slice: after mutating the first result,
a second lookup returns [599 599], want [429 503]
It also covers the behavioural half — after a caller mutates the result, a 429 must still retry — and passes under -race.
2. The parity guard never ran in CI
scripts/check-retry-metadata-parity.py was reachable only through the root check target, and no workflow invokes it. grep -rn "check-retry-metadata-parity\|make check" .github/ returned nothing. Retry metadata could therefore drift into main unnoticed — the exact failure the guard was added to prevent. Now wired into the Go job beside the idempotency guard it was modelled on, and the Makefile comment matches that sibling's "enforced in CI" convention.
Stating the residual honestly, because it is narrower than it first appears: retry_on is uniform [429, 503] across all 226 operations, so a Go template regression would be global and generated_retry_statusset_test.go already catches it in CI. What this guard uniquely covers is a generator bug in the TypeScript, Kotlin, Swift, or Ruby metadata values, plus the criterion-2 consumption token-smoke. That makes it low severity, not medium.
Verification
| Check | Result |
|---|---|
| Regression test vs unfixed accessor | fails with the leak message above |
go test ./pkg/basecamp/ -run TestGeneratedRetryOn -race | 3/3 pass |
go test ./... | all packages ok |
make go-check (clean lint cache) | exit 0 |
make go-check-generated-drift | no drift — committed output matches the template |
make check-retry-metadata-parity | exit 0, 226 operations |
make lint-actions (actionlint + zizmor) | no findings |
The regenerated diff is exactly the accessor — 13 insertions, 3 deletions, no incidental churn.
Deliberately not touched
- Python and SPEC.md. Four of #486's six review claims described code that was already correct at the merge tree; three of those were fixed before the squash while their threads stayed open, and the SPEC paragraph Codex flagged was rewritten by #486's own merge commit. Nothing to do.
python/README.md:452still says GETs retry on "retryableApiError(500, 502, 503, 504)", but the merged gate is the declared{429, 503}set. That is a real stale doc introduced by #486, but it is out of scope here and belongs in its own change.
.github/workflows/ is a control-plane path, so the sensitive-change gate will comment — informational, shadow mode.
Summary by cubic
Return a copy from GetOperationRetryOn to prevent global retry policy mutation and data races. Add a CI step to enforce retry metadata parity across SDKs.
-
Bug Fixes
GetOperationRetryOnnow returns a copy of the per-operation status set, preserving theoksignal to distinguish empty vs. absent.- Updated the Go template and regenerated the client to apply the fix.
-
New Features
- CI runs
make check-retry-metadata-parityto enforce cross-SDK retry metadata parity alongside the idempotency guard.
- CI runs