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

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

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

opened this

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, unauthorized and forbidden → unauthorized, and unreachable and invalid_response → unreachable. A second test checks that a value outside the type also reads as unreachable.
  • Type check: the expected words sit in a Record<ProviderError, …>. Adding a failure kind to the type without deciding its word fails tsc on 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.

Closes #6657

commented

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, unauthorized and forbidden → unauthorized, and unreachable and invalid_response → unreachable. A second test checks that a value outside the type also reads as unreachable.
  • Type check: the expected words sit in a Record<ProviderError, …>. Adding a failure kind to the type without deciding its word fails tsc on 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.

Approved

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.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs