fix(api): /auth/github + /auth/google/callback agent-actionable missing-field copy (BUG-API-184)#195
Merged
Conversation
7e621a1 to
cbde2a3
Compare
…ng-field copy (BUG-API-184)
POST /auth/github body `{}` used to return:
error: "missing_code"
message: "code field is required"
Accurate, but agent-unhelpful. An LLM hitting this 4xx needed to either
know the GitHub OAuth code-exchange contract already or open
/openapi.json to learn what to send.
Stamp the full request-body shape in the message so the agent can retry
without a second round trip:
"Request body is missing the required `code` field. POST
`{\"code\": \"<github_oauth_code>\"}` after exchanging your OAuth
authorization code at GitHub."
Per rule 16 (enumerate ALL call sites), the same `"code field is
required"` string lived on /auth/google/callback — mirrored the same
upgrade there, plus the adjacent `missing_redirect_uri` message.
Error codes (`missing_code`, `missing_redirect_uri`) stay stable so
agents branching on `.error` are unaffected.
Coverage block:
Symptom: /auth/github POST nofields 400 — message should list required fields
(BUG-API-184)
Enumeration: rg -F 'code field is required' internal/ (2 sites)
rg -F 'redirect_uri field is required' internal/ (1 site)
rg -F 'missing_code' internal/handlers/ (2 emit sites in auth.go)
Sites found: 2 missing_code emits + 1 missing_redirect_uri emit
Sites touched: 3
Coverage test: TestAuth_GitHub_MissingCodeAndBadBody asserts message contains
both ``code`` (the field name) and `{"code":` (the body shape).
Error code unchanged so back-compat tests stay green.
Live verified: pending auto-deploy +
curl -s -X POST -H 'Content-Type: application/json' -d '{}' \
https://api.instanode.dev/auth/github | jq .message
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
cbde2a3 to
0db81ac
Compare
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
Coverage block
```
Symptom: /auth/github POST nofields 400 message should list required fields (BUG-API-184)
Enumeration: rg -F 'code field is required' internal/ (2 sites pre-fix)
rg -F 'redirect_uri field is required' internal/ (1 site pre-fix)
rg -F 'missing_code' internal/handlers/ (2 emit sites in auth.go)
Sites found: 2 missing_code emits + 1 missing_redirect_uri emit
Sites touched: 3 (rule 16 compliant)
Coverage test: TestAuth_GitHub_MissingCodeAndBadBody asserts:
- .error == "missing_code" (back-compat)
- .message contains `\
code\\` (the field name)- .message contains `{"code":` (the body shape)
so a future regression to the bare message fails before merge.
Live verified: pending auto-deploy +
curl -s -X POST -H 'Content-Type: application/json' -d '{}' \
https://api.instanode.dev/auth/github | jq .message
```
Inbox reference
Test plan
🤖 Generated with Claude Code