Error UX: friendly 403/404/429 messages + stable exit codes per failure class #134
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Task
Make failure reporting scriptable on two axes: stop leaking the internal
/api/v1URL, and give failure classes stable exit codes..context(...)treatment 401 already gets inensure_success(src/client/mod.rs:573): a short human sentence ("not found: /", "forbidden: token lacks scope / no access", "rate limited, retry after N s"), keeping the rawApiError(with the URL) as thecaused by:source linemain.rs:56-60already prints, so--debugdetail survives without leading with/api/v1/.run_cli(src/main.rs:54-62): downcastanyhow::ErrortoApiErrorand return distinct codes (e.g. 3 not-found, 4 auth/forbidden, 5 rate-limit/transient), keeping1as the generic fallback. Document them once.owner/name,#number) over the resolved URL in the headline.Source: rasterstate/fj#123.
Priority
p1. Distinct exit codes are the foundation of every "view the PR; if it doesn't exist, create it" agent pattern. Without them a script must capture stderr and string-match
404/couldn't be found, brittle across locales and server wording. There is no fallback that recovers a reliable failure-kind signal, which is what makes this a blocker rather than an ergonomics gap.Reason
ensure_successforks on exactly one status:401gets a friendly hint, every other non-2xx is a rawApiErrordump whoseDisplayisHTTP {status} from {url}: {message}withurlthe raw REST endpoint (src/client/error.rs:6-13). So a typo'd repo surfacesHTTP 404 Not Found from https://.../api/v1/repos/..., leaking plumbing the CLI otherwise hides and reading as "fj broke." Separately,main.rsmaps anyErrtoExitCode::from(1)(:54-62), so not-found, auth, rate-limit, and transport failures are indistinguishable. The existing 401 branch proves the maintainers already value a friendly hint; 404/403/429 just never got the same treatment.Acceptance
ApiError(URL included) survives as thecaused by:source line under--debug.1as the generic fallback; clap usage errors keep clap's code.owner/name/#number, not the resolved/api/v1URL.src/client/integration_tests.rsasserting headline text and exit-code class per status.docs/), so scripts can rely on it.cargo fmt --check,cargo clippy --all-targets --all-features -- -D warnings, andcargo test --allpass.Dependencies
None. Distinct from rasterstate/fj#125, which is about a successful command observing a failed run (this is about failed API calls). Touches the single
ensure_success/main.rserror path; no parallel code path.Size
M
/api/v1URL and every failure exits 1, so scripts cannot branch on failure kind #123