An expired session fails with one line saying to run quak login, exit 3 #164

Closed
opened 2026-10-06 01:16:51 +02:00 by clawbot · 0 comments
Collaborator

Part of #162 (one cron-safe command that mirrors the whole account).

What

A command run from the saved session whose token the server no longer accepts (HTTP 401) fails with one line telling the user to run quak login, and a distinct exit code a cron job can act on.

Definition of done

  • When a command that uses the saved session gets a 401 from the server, it prints exactly one line to stderr that names quak login (for example quak: the saved session is no longer valid; run "quak login") and exits 3. No stack trace, no second line.
  • "Not logged in" and "session file is corrupt" keep their current messages and also exit 3: all three mean the user must log in again.
  • quak backup, the command cron runs, gets this on the refresh that starts every run, before any file is touched.
  • No command run from the saved session ever prompts (a test with a context whose prompt throws covers backup).
  • README "Session handling": the exit status sentence says 3 for all three cases, and describes the expired-session line.
  • Tests with stand-ins, never the real service: a 401 on the refresh gives the one line and exit 3; not logged in and a corrupt file exit 3; another error still exits 1.
  • TODO.md: an entry at the top of Completed Steps.

Notes

Find where the 401 reaches the CLI. If the library passes the ApiError up (directly or as a cause), recognising it in one place, run in src/cli-run.ts, is the plain way; check the error that actually arrives through Library.open and lib.backup().

Out of scope: a session revoked in the middle of a run makes the remaining downloads fail one by one into failures.json (exit 1); the next run then stops at the refresh with exit 3.

Touches src/cli-run.ts, src/cli-commands.ts (session loading only), tests, README.md, TODO.md. Units in flight beside it change src/backup.ts, src/library/index.ts, src/retry.ts and bin/quak.ts; leave those alone.

Model: opus-5-5

Part of https://git.eeqj.de/sneak/quak/issues/162 (one cron-safe command that mirrors the whole account). ## What A command run from the saved session whose token the server no longer accepts (HTTP 401) fails with one line telling the user to run `quak login`, and a distinct exit code a cron job can act on. ## Definition of done - When a command that uses the saved session gets a 401 from the server, it prints exactly one line to stderr that names `quak login` (for example `quak: the saved session is no longer valid; run "quak login"`) and exits 3. No stack trace, no second line. - "Not logged in" and "session file is corrupt" keep their current messages and also exit 3: all three mean the user must log in again. - `quak backup`, the command cron runs, gets this on the refresh that starts every run, before any file is touched. - No command run from the saved session ever prompts (a test with a context whose `prompt` throws covers `backup`). - README "Session handling": the exit status sentence says 3 for all three cases, and describes the expired-session line. - Tests with stand-ins, never the real service: a 401 on the refresh gives the one line and exit 3; not logged in and a corrupt file exit 3; another error still exits 1. - `TODO.md`: an entry at the top of Completed Steps. ## Notes Find where the 401 reaches the CLI. If the library passes the `ApiError` up (directly or as a `cause`), recognising it in one place, `run` in `src/cli-run.ts`, is the plain way; check the error that actually arrives through `Library.open` and `lib.backup()`. Out of scope: a session revoked in the middle of a run makes the remaining downloads fail one by one into `failures.json` (exit 1); the next run then stops at the refresh with exit 3. Touches `src/cli-run.ts`, `src/cli-commands.ts` (session loading only), tests, `README.md`, `TODO.md`. Units in flight beside it change `src/backup.ts`, `src/library/index.ts`, `src/retry.ts` and `bin/quak.ts`; leave those alone. Model: opus-5-5
clawbot self-assigned this 2026-10-06 01:16:51 +02:00
Sign in to join this conversation.