Commit 4e36b7a
fix(api): /auth/email/confirm-deletion JSON envelope (BUG-API-047/204/273)
The missing-token branch on /auth/email/confirm-deletion used to
`SendString("Missing token")` which served `Content-Type: text/plain`
with no envelope, no request_id, no agent_action — an envelope-bypass
that broke the universal {ok,error,message,request_id,agent_action}
contract every other 4xx in the api carries.
Agents grepping on `error: missing_token` (the canonical code already
used across onboarding.go, deletion_confirm.go:275, magic_link.go)
silently failed because this surface returned a plain string.
Route through respondError so the envelope shape + the existing
codeToAgentAction[missing_token] entry land here too.
The handler is browser-initiated (email-link click) but the response
shape must match the rest of the API for agent-driven probes (e.g. an
MCP tool unwrapping the JSON envelope before opening the dashboard).
Coverage block:
Symptom: /auth/email/confirm-deletion returns text/plain 400 with no
envelope (BUG-API-047, BUG-API-204, BUG-API-273)
Enumeration: rg -F 'SendString' internal/handlers/deletion_confirm.go (1 site)
rg -F 'confirm-deletion' internal/router/router.go (route bind)
Sites found: 1 (deletion_confirm.go:510 SendString)
Sites touched: 1
Coverage test: TestEmailConfirmDeletionRedirectHandler now asserts:
- status 400
- Content-Type application/json
- envelope.ok == false
- envelope.error == "missing_token"
- envelope.message non-empty
- envelope.agent_action non-empty (from codeToAgentAction)
so a future revert to SendString fails before merge.
Live verified: pending auto-deploy + curl -sI 'https://api.instanode.dev/auth/email/confirm-deletion' | grep -i content-type
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent eedce75 commit 4e36b7a
2 files changed
Lines changed: 68 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
507 | 507 | | |
508 | 508 | | |
509 | 509 | | |
510 | | - | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
511 | 527 | | |
512 | 528 | | |
513 | 529 | | |
| |||
Lines changed: 51 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
12 | 15 | | |
13 | 16 | | |
14 | 17 | | |
| |||
130 | 133 | | |
131 | 134 | | |
132 | 135 | | |
133 | | - | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
134 | 149 | | |
135 | 150 | | |
136 | | - | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
137 | 157 | | |
138 | 158 | | |
139 | 159 | | |
140 | 160 | | |
141 | 161 | | |
142 | 162 | | |
143 | 163 | | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
144 | 169 | | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
145 | 194 | | |
146 | 195 | | |
147 | 196 | | |
| |||
0 commit comments