Public: anyone can read this; the crew can change it.
A test pins how an origin's refusal reads: `toSourceError` folds forbidden into unauthorized and anything unknown into unreachable #6665
Check · Review · Land · Live done — Landed and live in production.
I added `test/view-origin-errors.test.ts`, which pins what `toSourceError` in `src/view/origin.ts` returns for every `ProviderError`. `bun x tsc --noEmit` is clean and the new test file passes (2 tests); I did not run the rest of the suite.
shipped production is serving it deploy 4915f35
I added test/view-origin-errors.test.ts, which pins what toSourceError in src/view/origin.ts returns for every ProviderError. bun x tsc --noEmit is clean and the new test file passes (2 tests); I did not run the rest of the suite.
- Mapping: the test pins
not_found→not_found,rate_limited→rate_limited,unauthorizedandforbidden→unauthorized, andunreachableandinvalid_response→unreachable. A second test checks that a value outside the type also reads asunreachable. - Type check: the expected words sit in a
Record<ProviderError, …>. Adding a failure kind to the type without deciding its word failstscon that test file. - Left out: there are no source changes. The function already behaved as the issue describes.
To try it, run bun test test/view-origin-errors.test.ts.
Test-only change that pins toSourceError exactly as the source behaves: forbidden folds into unauthorized, unreachable and invalid_response read as unreachable, and an unknown value falls to unreachable. The Record<ProviderError, ...> keying makes tsc fail when a failure kind is added without a decision. There is no UI or runtime surface, so the security, terminal and README items do not apply. Two things to do next: (1) the sibling mapping in the other direction, if one exists, deserves the same pin; (2) the loop reads Object.entries, so the cast error as ProviderError is only needed because keys widen to string. A typed key list would drop it, but this is minor.
I added
test/view-origin-errors.test.ts, which pins whattoSourceErrorinsrc/view/origin.tsreturns for everyProviderError.bun x tsc --noEmitis clean and the new test file passes (2 tests); I did not run the rest of the suite.not_found→not_found,rate_limited→rate_limited,unauthorizedandforbidden→unauthorized, andunreachableandinvalid_response→unreachable. A second test checks that a value outside the type also reads asunreachable.Record<ProviderError, …>. Adding a failure kind to the type without deciding its word failstscon that test file.To try it, run
bun test test/view-origin-errors.test.ts.Closes #6657