Skip to content

fix(handlers): canonical error envelope (request_id) on 3 agent-facing branches#234

Merged
mastermanas805 merged 4 commits into
masterfrom
fix/error-envelope-request-id-2026-06-04
Jun 3, 2026
Merged

fix(handlers): canonical error envelope (request_id) on 3 agent-facing branches#234
mastermanas805 merged 4 commits into
masterfrom
fix/error-envelope-request-id-2026-06-04

Conversation

@mastermanas805

Copy link
Copy Markdown
Member

What

Three agent-facing error branches emitted a bespoke envelope missing request_id (and one used a non-standard "msg" key), so an agent couldn't correlate the failure to logs/support the way every respondError path allows.

Site Before After
onboarding.go ClaimPreview invalid_token (not-found) {ok,error,msg} respondError{ok,error,message,request_id}
env_policy.go Put owner_required 403 {ok,error,role,allowed_roles,agent_action} + request_id
resource.go respondPauseUpgradeRequired 402 {ok,error,message,upgrade_url,agent_action} + request_id

Why it's safe

Additive only (request_id), plus the msgmessage rename on a branch whose documented shape was just {ok,error}. The machine-readable error keyword (what clients branch on) is unchanged on all three.

Symptom:        agent-facing 4xx missing request_id / non-canonical "msg" key
Enumeration:    grep across handlers for bespoke c.Status().JSON error envelopes
Sites found:    3 genuine agent-facing (webhook/HTML-page sites excluded as server-to-server / human-facing)
Sites touched:  3
Coverage:       all 3 changed lines covered by existing tests (count=1)
Live verified:  go test against real Postgres+Redis, green

🤖 Generated with Claude Code

…g branches

Three agent-facing error branches emitted a bespoke envelope missing
request_id (and one used a non-standard "msg" key), so an agent couldn't
correlate the failure to logs/support the way every respondError path lets it:

- onboarding.go ClaimPreview invalid_token (not-found): routed through
  respondError — adds request_id, swaps the bespoke "msg" for the canonical
  "message" key. The `error` keyword (what clients match on) is unchanged.
- env_policy.go Put owner_required 403: added request_id alongside the
  existing role/allowed_roles/agent_action fields.
- resource.go respondPauseUpgradeRequired 402: added request_id alongside
  the existing upgrade_url/agent_action.

No contract break — only additive (request_id) plus the msg→message rename on
a branch whose documented shape was just {ok,error}. All three changed lines
covered by existing tests (claim-preview not-found, env-policy non-owner,
pause-tier-wall); verified locally against real Postgres+Redis.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@mastermanas805 mastermanas805 enabled auto-merge (squash) June 3, 2026 19:24
@mastermanas805 mastermanas805 merged commit 6cef45b into master Jun 3, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant