Commit 07ab496
fix(errors): address Copilot review on WriteHTTPError JSON envelope (#112)
Copilot flagged three callers that would render the new
{"success":false,"message":...} envelope opaquely:
1. services.templ service-control: did `await response.text()` and
toasted the raw blob.
2. certificates.templ downloadCertificate: same.
3. security.templ blockIP / unblockIP: same.
Also flagged the 2xx-non-JSON fallback I added in logs.templ and
services.templ as too permissive — silently rendering a non-JSON 2xx
response would hide an auth-redirect HTML page or proxy error.
Fixes:
* security.templ now defines an `extractErrorMessage(response)`
helper that parses the JSON envelope when content-type advertises
JSON, falling back to text otherwise. blockIP / unblockIP route
through it.
* services.templ service-control inlines the same JSON-first
pattern.
* certificates.templ downloadCertificate inlines the same pattern.
* logs.templ + services.templ success-path: a 2xx with a non-JSON
body now throws a "non-JSON response" error instead of being
silently rendered as log lines / empty service list.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 409334d commit 07ab496
4 files changed
Lines changed: 69 additions & 11 deletions
File tree
- gearbox/internal/framework/templates/pages
Lines changed: 17 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
470 | 470 | | |
471 | 471 | | |
472 | 472 | | |
473 | | - | |
474 | | - | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
475 | 490 | | |
476 | 491 | | |
477 | 492 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
494 | 494 | | |
495 | 495 | | |
496 | 496 | | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
497 | 500 | | |
498 | 501 | | |
499 | 502 | | |
| |||
508 | 511 | | |
509 | 512 | | |
510 | 513 | | |
511 | | - | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
512 | 518 | | |
513 | 519 | | |
514 | 520 | | |
| |||
Lines changed: 20 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
200 | 200 | | |
201 | 201 | | |
202 | 202 | | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
203 | 221 | | |
204 | 222 | | |
205 | 223 | | |
| |||
363 | 381 | | |
364 | 382 | | |
365 | 383 | | |
366 | | - | |
367 | | - | |
| 384 | + | |
368 | 385 | | |
369 | 386 | | |
370 | 387 | | |
| |||
391 | 408 | | |
392 | 409 | | |
393 | 410 | | |
394 | | - | |
395 | | - | |
| 411 | + | |
396 | 412 | | |
397 | 413 | | |
398 | 414 | | |
| |||
Lines changed: 25 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
217 | 217 | | |
218 | 218 | | |
219 | 219 | | |
220 | | - | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
221 | 224 | | |
222 | 225 | | |
223 | 226 | | |
| |||
232 | 235 | | |
233 | 236 | | |
234 | 237 | | |
235 | | - | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
236 | 242 | | |
237 | 243 | | |
238 | 244 | | |
| |||
520 | 526 | | |
521 | 527 | | |
522 | 528 | | |
523 | | - | |
524 | | - | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
525 | 546 | | |
526 | 547 | | |
527 | 548 | | |
| |||
0 commit comments