Skip to content

fix: read a device sign-in's answer from the whole JSON, not its last line - #15

Merged
jeremy-robotsson merged 1 commit into
mainfrom
fix/wait-json-whole-output
Nov 19, 2026
Merged

jeremy-robotsson merged 1 commit into
mainfrom
fix/wait-json-whole-output

Conversation

@jeremy-robotsson

Copy link
Copy Markdown
Member

varlatch login --wait --json prints indented JSON, in the TypeScript CLI and in the Go CLI alike:

{
  "version": 1,
  "state": "denied"
}

The device sign-in read the state from the output's last line (tail -n 1 | jq). That line is }, so a denied or expired sign-in was reported as a generic "Sign-in failed" with the CLI's error lines, instead of "was denied" or "expired before it was approved".

Changes

  • bin/varlatch-menu: the state is read from the last whole JSON document in the output (jq -rs 'last | .state'). device-wait runs --wait again while the code is pending, so the output can hold several documents. The last one is the answer.
  • tests/fake-varlatch: login --start --json and every --wait --json answer are now printed as the CLIs print them: indented, with "version": 1. The old one-line JSON is what hid the bug.
  • tests/run.sh: a new case, "denied after a pending answer", where the output holds two documents.

Tests

  • tests/run.sh: 88 passed, 0 failed.
  • The same suite with the old bin/varlatch-menu: 3 failures ("denied", "the code expired", "denied after a pending answer"). The new fake catches the bug.
  • shellcheck (-S warning, as CI runs it) is clean.

No version bump or changelog entry: those come with the next release, which waits for the owner.

🤖 Generated with Claude Code

… line

`varlatch login --wait --json` prints indented JSON, so the last line
is `}` and a denied or expired sign-in was reported as a generic failure.
The answer is now the last whole document in the output (device-wait
asks again while the code is pending, so there may be several). The fake
CLI prints the real, indented form, and a new case covers a pending
answer followed by a denial.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jeremy-robotsson
jeremy-robotsson marked this pull request as ready for review November 19, 2026 22:09
@jeremy-robotsson
jeremy-robotsson merged commit 0be6a00 into main Nov 19, 2026
1 check passed
@jeremy-robotsson
jeremy-robotsson deleted the fix/wait-json-whole-output branch November 19, 2026 22:28
@jeremy-robotsson jeremy-robotsson mentioned this pull request Nov 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant