Retry docs: correct the mutation and 401 claims, add Python to the roster

Merged
JE
4mo ago
+68-20

Documentation only — no behavior change. Every claim below was re-derived from source at d5604962.

SECURITY.md — two false bullets

"Mutations (POST/PUT/DELETE): NOT automatically retried on 429/503". They are. behavior-model.json flags 69 operations idempotent: true — all 45 PUTs, all 21 DELETEs, and 3 POSTs (CompleteTodo, PauseQuestion, SubscribeToCardColumn) — and those retry in Go's generated operation path, Python, TypeScript, Kotlin, and Swift. Ruby is the only transport that is GET-only (http.rb routes every non-GET to single_request), as is Go's separate hand-written pkg/basecamp helper. The bullet dates to #60, before the generated client existed.

The 39 non-idempotent POSTs are single-attempt everywhere, which is the property the bullet was reaching for — so the replacement states the gate as idempotency rather than "is it a mutation".

"401 responses: Token refresh attempted, then single retry for all methods". True in three transports, false in four:

SDK401 behavior
Go — hand-written pkg/basecampRefresh via AuthManager, then one retry (client.go:794-800)
Go — generated pkg/generatedNo reactive refresh. AuthTransport.RoundTrip fetches a token proactively (client.gen.go:19851); ParseHTTPError turns 401 into AuthError (:20237)
RubyRefresh, then one retry (http.rb:417)
Python (sync and async)Refresh, then one retry (_http.py:237, _async_http.py:237)
TypeScript / Kotlin / SwiftNo refresh; the 401 reaches the caller

Swift's HTTPClient.swift:157 re-runs the auth strategy before each retry, but 401 is not a retryable status, so that path never fires for a 401.

SPEC.md — Python was missing, Ruby was miscategorized

  • :11 "Five shipping SDKs" and :38 "consensus of Go, Ruby, TypeScript, Kotlin, Swift" both omitted Python. Six now.
  • :401 named "Go, Ruby, and Swift" as retrying network errors. Python belongs there (NetworkError is retryable=True and the loop keys off it). Ruby does not belong in the same group — it retries network errors only on GET, because request sends every non-GET to single_request. Listing it alongside Go/Swift implied a parity it does not have.
  • Appendix F had no Python row.

New: Gate 3 fidelity note

Gates 1 and 2 read behavior-model.json. Gate 3's parameters do not, in two SDKs — Go and Python substitute a client-global attempt count for the per-operation retry.max and treat a superset of retry_on as retryable. Go's OperationMetadata carries no attempt count at all. That is now stated in §7 and footnoted under Appendix F, and filed as #479 with the fix design.

Also filed #480: Subscribe and EnableCardColumnOnHold are under-classified as non-idempotent (Subscribe calls the identical Recording::Subscribable#subscribe that the flagged SubscribeToCardColumn calls; EnableCardColumnOnHold's create is unless @on_hold-guarded and its DELETE sibling is already flagged). Both verified against BC3 2f01d0da.

Deliberately left alone

  • SPEC.md:400 — "Implementations may expand this set to include other 5xx statuses" sanctions the Go/Python behavior. It should go, but only together with the #479 fix; removing it now would make the spec false in the other direction.
  • SPEC.md:407 / :411 / :1591 and waiver 2B.1 — the TypeScript one-retry cap is current, not stale: client.ts:1007 returns native fetch(retryRequest), bypassing middleware, so the X-Retry-Attempt header it sets is never re-consumed. conformance/runner/typescript/runner.test.ts:73-78 pins it.

make check passes.


Summary by cubic

Updates retry docs to match reality: idempotent mutations do retry on 429/503, 401 handling varies by SDK, and Python is now included. Also clarifies network-error retry behavior, per-transport 401 differences, Ruby’s raw-upload exception, and Gate 3 fidelity.

  • Bug Fixes

    • SECURITY.md: Replace “mutations never retry” with idempotency rules; Ruby and Go’s hand-written helper are GET-only; respect Retry-After; non-idempotent POSTs never retry on 429/503 or network errors.
    • SECURITY.md: Add per-SDK 401 matrix — reactive refresh only in hand-written Go, Ruby, and Python; generated Go *WithResponse fills JSON401 and returns no error; TypeScript service wrappers throw on 401 but the raw client returns { data, error } without throwing; Kotlin/Swift surface 401; Ruby raw uploads (post_raw/put_raw) do not replay.
  • Spec Updates

    • Add Python across the spec and Appendix F; update “five” to “six”; fix network-error grouping: Go/Python/Swift retry; Ruby GET-only; TypeScript retries only after a response; Kotlin doesn’t retry network errors; clarify OAuth discovery SSRF note (Swift out of scope).
    • Gate 3 fidelity: Go/Ruby retry a superset of retry_on; Python has no status gate (uses a retryable flag); TypeScript/Kotlin/Swift use the declared set. Ruby ignores per-operation retry ceilings; others honor them.