Go: map HTTP 400 to validation (not api_error) - #482
Conversation
Review carefully before merging. Consider a major version bump. |
|
Series — retry-contract follow-up (branch fresh off
#481 and #483 both touch |
There was a problem hiding this comment.
Pull request overview
Aligns the Go SDK’s HTTP error-code mapping with SPEC.md §6 and the other SDKs by correctly classifying HTTP 400 as validation (instead of falling through to api_error). This closes a documented spec/implementation mismatch and adds conformance + unit-test coverage for the 400 case.
Changes:
- Go: map
http.StatusBadRequest(400) toCodeValidationincheckResponse. - Conformance: add a
400 → validationcase toconformance/tests/error-mapping.json. - Spec + tests: update
SPEC.mdto remove the prior carve-out and add a Go unit test row for 400.
Tip
If you aren't ready for review, convert to a draft PR.
Click "Convert to draft" or run gh pr ready --undo.
Click "Ready for review" or run gh pr ready to reengage.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| SPEC.md | Updates §6 error-code table/mapping algorithm and non-retryable notes to reflect 400→validation as conformance-verified. |
| go/pkg/basecamp/helpers.go | Adds an explicit 400→CodeValidation branch in checkResponse. |
| go/pkg/basecamp/helpers_test.go | Adds a 400 row to the checkResponse status→code/retryability table test. |
| conformance/tests/error-mapping.json | Adds a conformance fixture asserting 400 maps to validation with retryable=false. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
SPEC §6 prescribes 400 -> validation to match the other five SDKs, but Go's checkResponse had no 400 case, so it fell through to the default arm and mislabeled 400 Bad Request as api_error. Add the missing case (code=validation, http_status=400, retryable=false). This resolves the [CONFLICT]/[static] carve-outs the SPEC carried for 400: mark the error-code table row, the mapping-algorithm step, and the non-retryable-errors note as [conformance]-verified, and drop the stale "Go currently maps 400 to api_error" note. Adds a 400 case to the shared error-mapping conformance fixture (verified green across all five runners: Go, Kotlin, TypeScript, Ruby, Python) and a 400 row to helpers_test.go (proven to fail pre-fix: api_error != validation). retryable stays false — this is a code/message correction, not a retry-behavior change. Follows the retry-contract program (#456/#460/#461/#476).
c5eb792 to
28a3be8
Compare
|
Addressed the bot review:
|
Problem
SPEC.md§6 prescribes400 → validationto match the other five SDKs, but Go'scheckResponsehad nocase http.StatusBadRequest, so 400 Bad Request fell through to thedefaultarm and was mislabeledapi_error. The SPEC self-tagged this as a[CONFLICT]/[static]carve-out with no conformance coverage.Fix
case http.StatusBadRequest → CodeValidation(retryable: false) togo/pkg/basecamp/helpers.go. This is a code/message correction, not a retry-behavior change.[conformance]-verified; drop the stale "Go currently maps 400 to api_error" note.400 → validationcase to the shared conformance fixtureconformance/tests/error-mapping.jsonand a 400 row tohelpers_test.go.Tests / Verify
helpers_test.go400 row proven to fail pre-fix (api_error!=validation).conformance-fixtures-check.Part of the retry-contract follow-up (#456 / #460 / #461 / #476). Independent of the other two PRs in the series (no shared files).
Summary by cubic
Maps HTTP 400 to
validationin the Go SDK to align with SPEC §6 and other SDKs. Adds conformance coverage and a unit test; 400 remains non-retryable.validationingo/pkg/basecamp/helpers.go(retryable: false).conformance/tests/error-mapping.jsonandhelpers_test.go.[conformance]; clarify mapping algorithm fallbacks.Written for commit 28a3be8. Summary will update on new commits.