Commit 0db81ac
fix(api): /auth/github + /auth/google/callback agent-actionable missing-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>1 parent 84d0e47 commit 0db81ac
2 files changed
Lines changed: 38 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
408 | 408 | | |
409 | 409 | | |
410 | 410 | | |
411 | | - | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
412 | 423 | | |
413 | 424 | | |
414 | 425 | | |
| |||
514 | 525 | | |
515 | 526 | | |
516 | 527 | | |
517 | | - | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
518 | 534 | | |
519 | 535 | | |
520 | | - | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
521 | 540 | | |
522 | 541 | | |
523 | 542 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
248 | 248 | | |
249 | 249 | | |
250 | 250 | | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
251 | 261 | | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
252 | 268 | | |
253 | 269 | | |
254 | 270 | | |
| |||
0 commit comments