An expired session exits 3 with one line saying to run quak login (closes #164) #173

Merged
clawbot merged 1 commits from issue-164-expired-session-exit-3 into next 2026-10-06 14:01:50 +02:00
Collaborator

Implements #164, part of #162.

A 401 from the server reaches run in src/cli-run.ts as the ApiError the refresh threw: the API client does not retry a 401, and neither Library.open nor lib.backup() wraps it. So run recognises a 401 that ends a command, prints quak: the saved session is no longer valid; run "quak login" and exits 3. For the commands that load the saved session, a missing or corrupt session file keeps its message and also exits 3.

Library.open on an empty cache swallows its first refresh's failure and opens empty; the 401 then surfaces from the refresh lib.backup() starts, before any file in the backup directory is touched. The new backup test uses a real saved session read back by loadSession over a stand-in fetch that answers 401, so it covers that whole path; its context's prompts throw.

README "Session handling" and the CLI-surface sentence about a failed refresh now give exit 3; TODO.md has the entry.

Judgement call: quak logout is unchanged; it handles its own errors and deletes the session file whatever the server answers.
Judgement call: quak backup still prints "Starting backup..." and "Refreshing library..." before the error line; the second comes from src/backup.ts, which this unit leaves alone.

Model: opus-5-5

Implements https://git.eeqj.de/sneak/quak/issues/164, part of https://git.eeqj.de/sneak/quak/issues/162. A 401 from the server reaches `run` in `src/cli-run.ts` as the `ApiError` the refresh threw: the API client does not retry a 401, and neither `Library.open` nor `lib.backup()` wraps it. So `run` recognises a 401 that ends a command, prints `quak: the saved session is no longer valid; run "quak login"` and exits 3. For the commands that load the saved session, a missing or corrupt session file keeps its message and also exits 3. `Library.open` on an empty cache swallows its first refresh's failure and opens empty; the 401 then surfaces from the refresh `lib.backup()` starts, before any file in the backup directory is touched. The new backup test uses a real saved session read back by `loadSession` over a stand-in fetch that answers 401, so it covers that whole path; its context's prompts throw. README "Session handling" and the CLI-surface sentence about a failed refresh now give exit 3; `TODO.md` has the entry. Judgement call: `quak logout` is unchanged; it handles its own errors and deletes the session file whatever the server answers. Judgement call: `quak backup` still prints "Starting backup..." and "Refreshing library..." before the error line; the second comes from `src/backup.ts`, which this unit leaves alone. Model: opus-5-5
clawbot self-assigned this 2026-10-06 01:50:50 +02:00
clawbot added the needs-review label 2026-10-06 01:50:54 +02:00
Author
Collaborator
  1. README.md, "Session handling": the new sentence says any HTTP 401 a command meets prints the one line and exits 3. That holds only for the refresh each command starts with; a session revoked partway through quak backup fails the remaining files into failures.json and exits 1, as decided on #162. Acceptable: tie the sentence to that first refresh, or add one sentence for the mid-run case.

  2. test/cli/commands.test.ts: exit 3 for a missing session file is asserted only for whoami, and for a corrupt one only for collections. Nothing tests that backup, the command cron runs, exits 3 with no session file. Acceptable: a test that runs backup (better, each command that loads the session) with no session file and expects 3.

Model: opus-5-5

1. `README.md`, "Session handling": the new sentence says any HTTP 401 a command meets prints the one line and exits 3. That holds only for the refresh each command starts with; a session revoked partway through `quak backup` fails the remaining files into `failures.json` and exits 1, as decided on https://git.eeqj.de/sneak/quak/issues/162. Acceptable: tie the sentence to that first refresh, or add one sentence for the mid-run case. 2. `test/cli/commands.test.ts`: exit 3 for a missing session file is asserted only for `whoami`, and for a corrupt one only for `collections`. Nothing tests that `backup`, the command cron runs, exits 3 with no session file. Acceptable: a test that runs `backup` (better, each command that loads the session) with no session file and expects 3. Model: opus-5-5
clawbot added needs-rework and removed needs-review labels 2026-10-06 02:36:08 +02:00
clawbot force-pushed issue-164-expired-session-exit-3 from 0f7574b4ca to 1283048ce2 2026-10-06 03:55:07 +02:00 Compare
clawbot added needs-review and removed needs-rework labels 2026-10-06 03:55:14 +02:00
Author
Collaborator
  1. README "Session handling": the 401 line and exit 3 are now tied to the refresh a command starts with, plus one sentence for a session that stops working partway through a backup (remaining files go to failures.json, that run exits 1, the next stops at its refresh with 3).
  2. The missing-session test now runs every command that loads the session, backup included, and expects exit 3 and the "Not logged in" message from each, with no backup directory created.

Model: opus-5-5

1. README "Session handling": the 401 line and exit 3 are now tied to the refresh a command starts with, plus one sentence for a session that stops working partway through a backup (remaining files go to `failures.json`, that run exits 1, the next stops at its refresh with 3). 2. The missing-session test now runs every command that loads the session, `backup` included, and expects exit 3 and the "Not logged in" message from each, with no backup directory created. Model: opus-5-5
Author
Collaborator
  1. Needs rebase onto current next. It conflicts with the ML-data change from #163 in two files. In TODO.md, both entries belong at the top of Completed Steps. In test/cli/commands.test.ts, next still has the old refresh-failure test, which throws "HTTP 401 from server" and expects exit 1. Acceptable: rebased onto next, keeping the new ML-data test and replacing that old test with this PR's 503 and 401 tests.

  2. TODO.md, the new Completed Steps entry: the first sentence says that any command whose saved session the server no longer accepts prints the one line and exits 3. That is not true of quak logout, which reports the failed server call and exits 1. It is not true of quak whoami, which does not contact the server. And it is not true of a session that stops working partway through a backup, which exits 1. The earlier review found the same over-broad claim in the README; the README was fixed, this entry was not. Acceptable: tie the sentence to the refresh a command starts with, as the README now does.

Model: opus-5-5

1. Needs rebase onto current `next`. It conflicts with the ML-data change from https://git.eeqj.de/sneak/quak/issues/163 in two files. In `TODO.md`, both entries belong at the top of Completed Steps. In `test/cli/commands.test.ts`, `next` still has the old refresh-failure test, which throws "HTTP 401 from server" and expects exit 1. Acceptable: rebased onto `next`, keeping the new ML-data test and replacing that old test with this PR's 503 and 401 tests. 2. `TODO.md`, the new Completed Steps entry: the first sentence says that any command whose saved session the server no longer accepts prints the one line and exits 3. That is not true of `quak logout`, which reports the failed server call and exits 1. It is not true of `quak whoami`, which does not contact the server. And it is not true of a session that stops working partway through a backup, which exits 1. The earlier review found the same over-broad claim in the README; the README was fixed, this entry was not. Acceptable: tie the sentence to the refresh a command starts with, as the README now does. Model: opus-5-5
clawbot added needs-rework and removed needs-review labels 2026-10-06 06:23:58 +02:00
clawbot force-pushed issue-164-expired-session-exit-3 from 1283048ce2 to 6967117cee 2026-10-06 07:04:01 +02:00 Compare
clawbot added needs-review and removed needs-rework labels 2026-10-06 07:04:06 +02:00
Author
Collaborator
  1. Rebased onto next. In TODO.md this entry sits above the ML-data entry from #163. In test/cli/commands.test.ts the ML-data test stays, and the old refresh-failure test is replaced by this PR's 503 and 401 tests.
  2. The TODO.md entry now says the line and exit 3 come from the refresh a command starts with, as the README does.

Model: opus-5-5

1. Rebased onto `next`. In `TODO.md` this entry sits above the ML-data entry from https://git.eeqj.de/sneak/quak/issues/163. In `test/cli/commands.test.ts` the ML-data test stays, and the old refresh-failure test is replaced by this PR's 503 and 401 tests. 2. The `TODO.md` entry now says the line and exit 3 come from the refresh a command starts with, as the README does. Model: opus-5-5
clawbot force-pushed issue-164-expired-session-exit-3 from 6967117cee to 41304fb7db 2026-10-06 07:58:51 +02:00 Compare
Author
Collaborator

Rebased onto next. In TODO.md this entry sits at the top of Completed Steps, above the entry from #166, and is now dated 2026-10-06. Nothing else changed.

Model: opus-5-5

Rebased onto `next`. In `TODO.md` this entry sits at the top of Completed Steps, above the entry from https://git.eeqj.de/sneak/quak/issues/166, and is now dated 2026-10-06. Nothing else changed. Model: opus-5-5
Author
Collaborator
  1. TODO.md, the new Completed Steps entry: two sentences are not true of the code. "A missing or corrupt session file keeps its message and now also exits 3" does not hold for quak logout, which exits 0 with no session file and 1 with a corrupt one. "Every other error still exits 1" does not hold for a 401 met after the refresh, such as on the download in quak get: run turns that into the same one line and exit 3. The commit message repeats both sentences. Acceptable: limit the first sentence to the commands that load the saved session, as the README does, and narrow or drop the last one, in the entry and in the commit message.

Model: opus-5-5

1. `TODO.md`, the new Completed Steps entry: two sentences are not true of the code. "A missing or corrupt session file keeps its message and now also exits 3" does not hold for `quak logout`, which exits 0 with no session file and 1 with a corrupt one. "Every other error still exits 1" does not hold for a 401 met after the refresh, such as on the download in `quak get`: `run` turns that into the same one line and exit 3. The commit message repeats both sentences. Acceptable: limit the first sentence to the commands that load the saved session, as the README does, and narrow or drop the last one, in the entry and in the commit message. Model: opus-5-5
clawbot added needs-rework and removed needs-review labels 2026-10-06 08:33:52 +02:00
clawbot force-pushed issue-164-expired-session-exit-3 from 41304fb7db to 852416110e 2026-10-06 09:29:55 +02:00 Compare
clawbot added needs-review and removed needs-rework labels 2026-10-06 09:30:03 +02:00
Author
Collaborator

The TODO.md entry and the commit message were narrowed as the review asked.

Model: opus-5-5

The `TODO.md` entry and the commit message were narrowed as the review asked. Model: opus-5-5
Author
Collaborator

Review passed.

Model: opus-5-5

Review passed. Model: opus-5-5
clawbot added 1 commit 2026-10-06 13:56:44 +02:00
A 401 from the server that ends a command reaches run in src/cli-run.ts as
an ApiError; run prints one line saying to run "quak login" and exits 3.
quak backup meets it on its first refresh, before it touches any file. For
the commands that load the saved session, a missing or corrupt session file
keeps its message and also exits 3.

Judgement call: quak logout is unchanged; it handles its own errors and
deletes the session file whatever the server answers.
Judgement call: quak backup still prints its two progress lines before the
error line.

Model: opus-5-5
clawbot force-pushed issue-164-expired-session-exit-3 from 852416110e to b8c5a26552 2026-10-06 13:56:44 +02:00 Compare
clawbot merged commit f6317109bc into next 2026-10-06 14:01:50 +02:00
clawbot deleted branch issue-164-expired-session-exit-3 2026-10-06 14:01:51 +02:00
Sign in to join this conversation.