Skip to content

[Hackathon] Batch --wait auth failure exits 3 but the JSON envelope says CLI_ERROR #398

Closed

Description

@tujack39

Verified against (commit SHA or released version)

988c035 (main HEAD as of 2026-10-16; re-verified today, no drift from the researched baseline)

Discord Username / User ID

johnlu1976 (unique username: johnlu1976_18245)

What does this improvement do?

Pass the real auth error code through CLIError's code parameter in the batch --wait auth branch, so envelope code, exit code, and message agree.

Details / implementation notes

Problem statement:
resolveWaitFailure() in src/lib/wait-exit.ts (L159-167): the auth branch constructs new CLIError(message, 3) — exit code 3 is the documented auth code — but CLIError defaults code to 'CLI_ERROR'. So with --output json, error.code reads CLI_ERROR while the message admits it is an auth failure and the process exit code is 3 (auth). Telemetry's errorCode inherits the same misclassification. The CLI contradicts itself inside one error: message says auth, exit code says auth, code says generic error.

Reproduction: trigger an auth failure under batch --wait with --output json; compare error.code (CLI_ERROR) against the exit code (3) and message (auth).

Expected: the envelope carries the real member code for auth (use the existing code constructor parameter — one-line-level change), so error.code, exit code, and message agree; telemetry classifies it as auth.

Suggested fix: pass the proper error code through CLIError's existing code param in the auth branch; add a unit test asserting envelope/exit-code/message consistency.

Why it matters: agents and CI branch on error.code to decide re-auth; a lying code field sends them down the wrong path.


I plan to open a PR for this. Claiming via /assign below.

Activity

  1. tujack39 commented on Oct 16, 2026

    @tujack39
    ContributorAuthor

    /assign

  2. testsprite-hob commented on Oct 16, 2026

    @testsprite-hob

    Thanks for the interest, @tujack39! This issue hasn't been accepted for implementation yet — see the triage comment (a maintainer will label it accepted once it is). Feel free to check back, or ping us on Discord if it's been quiet.

  3. zeshi-du commented on Oct 20, 2026

    @zeshi-du
    Contributor

    Thanks @tujack39, accepted. Confirmed on v0.15.0: in resolveWaitFailure (src/lib/wait-exit.ts, auth branch) the error is built as new CLIError(message, 3), so code falls back to CLI_ERROR while the exit code is 3.

    Scope:

    • Auth branch only: pass the member's real code (authErr.error.code: AUTH_REQUIRED / AUTH_INVALID / AUTH_FORBIDDEN) as the third CLIError argument.
    • Keep exit code 3 and the message text unchanged. Don't touch other branches or the precedence order.
    • Add a unit test in src/lib/wait-exit.test.ts for the three auth codes (code, exit code, message), and confirm it fails before your change.
    • Don't modify the deferred/exit-7 handling in test.ts; that is tracked separately.

    Run npm test, lint and format before opening the PR. Go ahead and take it (/assign).

  4. added
    accepted
    on Oct 20, 2026
  5. tujack39 commented on Oct 20, 2026

    @tujack39
    ContributorAuthor

    /assign

  6. added
    in-progress
    on Oct 20, 2026
  7. testsprite-hob commented on Oct 20, 2026

    @testsprite-hob

    Assigned to @tujack39. Thanks for taking this on. (2 more slots available.)

    Your open assigned issues (1/3):
    (none)

  8. added a commit that references this issue on Nov 9, 2026
    3077947
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

acceptedin-progress

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions