Commit 3b6cebb
committed
fix(console): marketplace read cloud errors seven different ways — two of them break on the conversion, two are broken today (cloud#944)
`service-cloud` answers failures in two shapes and is mid-conversion between
them (cloud#944):
{ success: false, error: '<message>' } today, via `fail()`
{ success: false, error: { code, message } } the declared envelope
`marketplaceApi.ts` hand-rolled that read at seven call sites, in four
different ways. The spread was not harmless in either direction:
- TWO read `payload?.error` bare with no nested fallback. When the producer
converts, those receive an OBJECT where the surrounding type declares
`error?: string`. An object handed to a toast as a React child crashes the
page — objectstack#3913's exact symptom, which the actions route already
carries `interpretActionResponse` to prevent. Nothing typed catches it:
these payloads are `any`.
- TWO read only the nested form, so against a server shipping TODAY they
find nothing and degrade a real explanation into a bare status code.
So this is not only preparation. Two of the four defects are live: those sites
are swallowing messages users should be seeing right now.
One `readApiError(payload, res)` replaces all seven. It reads nested first,
then `fail()`'s bare string, then a top-level `message`, then `statusText`, and
it guarantees a STRING back — an unexpected shape degrades to the code rather
than travelling onward as an object, which is the property the two bare sites
needed. The `installPackage` site keeps its own `innerFailed` branch: that one
reads a different object (the HTTP-200-with-`data.success: false` shape), so
only its outer read is shared.
Tests pin all four dialects reading the same, the sibling-`code` form
(`failWithCode`), and that an unexpected shape can never leave as an object.
This is the consumer half of cloud#944's conversion order, and the reason that
order exists: the producer flip is two functions in
`cloud-artifact-helpers.ts`, but doing it before this lands breaks the console.
Same shape as objectui#2992 teaching `useAgents` four shapes before the
/ai/agents producers moved (objectstack#4053) — consumer first, then the server
converts on its own schedule.
Verified: 8 new tests pass, app-shell tsc clean. No behavior change against any
server shipping today except the two sites that start showing their message.
Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BZaiYNM5igzGk6JiibjShb1 parent eddd4a1 commit 3b6cebb
2 files changed
Lines changed: 137 additions & 17 deletions
Lines changed: 84 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
Lines changed: 53 additions & 17 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
41 | 83 | | |
42 | 84 | | |
43 | 85 | | |
| |||
143 | 185 | | |
144 | 186 | | |
145 | 187 | | |
146 | | - | |
147 | | - | |
| 188 | + | |
148 | 189 | | |
149 | 190 | | |
150 | 191 | | |
| |||
221 | 262 | | |
222 | 263 | | |
223 | 264 | | |
224 | | - | |
225 | | - | |
| 265 | + | |
226 | 266 | | |
227 | 267 | | |
228 | 268 | | |
| |||
255 | 295 | | |
256 | 296 | | |
257 | 297 | | |
258 | | - | |
259 | | - | |
260 | | - | |
261 | | - | |
262 | | - | |
263 | | - | |
264 | | - | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
265 | 303 | | |
266 | 304 | | |
267 | 305 | | |
| |||
488 | 526 | | |
489 | 527 | | |
490 | 528 | | |
491 | | - | |
| 529 | + | |
492 | 530 | | |
493 | 531 | | |
494 | 532 | | |
| |||
509 | 547 | | |
510 | 548 | | |
511 | 549 | | |
512 | | - | |
| 550 | + | |
513 | 551 | | |
514 | 552 | | |
515 | 553 | | |
| |||
604 | 642 | | |
605 | 643 | | |
606 | 644 | | |
607 | | - | |
608 | | - | |
| 645 | + | |
609 | 646 | | |
610 | 647 | | |
611 | 648 | | |
| |||
683 | 720 | | |
684 | 721 | | |
685 | 722 | | |
686 | | - | |
687 | | - | |
| 723 | + | |
688 | 724 | | |
689 | 725 | | |
690 | 726 | | |
| |||
0 commit comments