Commit 9fae51f
authored
fix(api): include request path in API error messages (#1224)
* fix(api): include request path in API error messages
Backport of v1.x #1094 to main. When a Socket API request fails,
we now always surface the endpoint path in the error message — not
just on the non-ok-response branch where we already had it.
Specifically:
* `queryApiSafeText` catch block (network error) — append `(path: ${path})`
* `queryApiSafeText` response-text-read catch — append `(path: ${path})`
* `sendApiRequest` catch block (network error) — append `(path: ${path})`
* `sendApiRequest` JSON-parse catch — append `(path: ${path})`
The `handleApiCall` / `handleApiCallNoSpinner` paths already include
`(endpoint: ${description})` so no change there.
Closes the coverage gap flagged in the v1.x changelog: "This lacks the
request URL, making it difficult to debug which endpoint failed."
* test(api): assert (path: …) suffix on error causes
The original #1224 change added `(path: <path>)` to four error causes
but the existing tests only asserted loose substrings like "failed" /
"parsing" / "response text", so a regression would slip by unnoticed.
Adds four targeted assertions inside the existing tests:
* queryApiSafeText — network-failure branch
* queryApiSafeText — text-read-failure branch
* sendApiRequest — network-failure branch
* sendApiRequest — JSON-parse-failure branch
Each now verifies `result.cause` contains `(path: test/path)`. No new
tests added — the existing ones already set up the right mocks for
each failure mode, so extending the assertion is the minimum change
to actually lock the behavior in.1 parent 806bc96 commit 9fae51f
File tree
2 files changed
+11
-4
lines changed- packages/cli
- src/utils/socket
- test/unit/utils/socket
2 files changed
+11
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
465 | 465 | | |
466 | 466 | | |
467 | 467 | | |
468 | | - | |
| 468 | + | |
469 | 469 | | |
470 | 470 | | |
471 | 471 | | |
| |||
506 | 506 | | |
507 | 507 | | |
508 | 508 | | |
509 | | - | |
| 509 | + | |
510 | 510 | | |
511 | 511 | | |
512 | 512 | | |
| |||
643 | 643 | | |
644 | 644 | | |
645 | 645 | | |
646 | | - | |
| 646 | + | |
647 | 647 | | |
648 | 648 | | |
649 | 649 | | |
| |||
686 | 686 | | |
687 | 687 | | |
688 | 688 | | |
689 | | - | |
| 689 | + | |
690 | 690 | | |
691 | 691 | | |
692 | 692 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
469 | 469 | | |
470 | 470 | | |
471 | 471 | | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
472 | 475 | | |
473 | 476 | | |
474 | 477 | | |
| |||
493 | 496 | | |
494 | 497 | | |
495 | 498 | | |
| 499 | + | |
496 | 500 | | |
497 | 501 | | |
498 | 502 | | |
| |||
628 | 632 | | |
629 | 633 | | |
630 | 634 | | |
| 635 | + | |
| 636 | + | |
631 | 637 | | |
632 | 638 | | |
633 | 639 | | |
| |||
642 | 648 | | |
643 | 649 | | |
644 | 650 | | |
| 651 | + | |
645 | 652 | | |
646 | 653 | | |
647 | 654 | | |
| |||
0 commit comments