Skip to content

fix(models): surface the auth login device-code conflict remedy - #198333

Closed
SunnyShu0925 wants to merge 1 commit into
openclaw:mainfrom
SunnyShu0925:fix/models-auth-login-conflict-remedy-308
Closed

SunnyShu0925 wants to merge 1 commit into
openclaw:mainfrom
SunnyShu0925:fix/models-auth-login-conflict-remedy-308

Conversation

@SunnyShu0925

Copy link
Copy Markdown
Contributor

What Problem This Solves

openclaw models auth login --device-code --method password rejects the conflicting flags but prints only [openclaw] The CLI command failed. followed by a doctor hint — the remedy the guard already composed (--device-code cannot be combined with --method unless method is device-code.) never reaches the operator. This change throws the conflict as an expected CLI error so the root failure renderer prints the remedy line directly.

  • Problem: the conflict guard in the models auth login action throws a plain Error. The root failure renderer prints humanOutput only for expected CLI errors, and models is not on the show-reason whitelist, so the message collapses to the generic failure title plus For help, run openclaw doctor.
  • Solution: replace throw new Error(...) with the canonical throwExpectedCliError(...) from src/cli/expected-cli-error.ts, keeping the message verbatim.
  • What changed: src/cli/models-cli.ts (one import, one throw) and a regression assertion folded into the existing --device-code mapping test in src/cli/models-cli.test.ts (net 0 test lines, no new test file).
  • What did NOT change: the guard condition, the message text, the exit code (1), machine/JSON output, and every other command path.

Why This Change Was Made

The renderer already owns the remedy-printing contract: an expected CLI error carries humanOutput, and formatCliFailureLines prints it verbatim before any generic fallback. Reusing throwExpectedCliError is the established per-site remedy for this exact anti-pattern — the dns CLI fix #192127 adopted the same shape, including the rejects.toMatchObject({ humanOutput }) guard-test form reused here. Alternatives considered and rejected: adding models to the show-reason whitelist would widen reason printing for every models failure (a larger blast radius than this one guard), and constructing ExpectedCliError inline would duplicate the owner. The production delta is +1 line (the import); the throw itself is a one-for-one replacement.

User Impact

Operators who combine --device-code with an incompatible --method now see the actionable remedy line directly instead of a generic failure and a doctor hint. Valid invocations are untouched, and the command still exits 1 on the conflict.

Evidence

Case Before (base 25559c4) After (this head)
models auth login --device-code --method password generic title + doctor hint, remedy hidden (exit 1) remedy line printed verbatim (exit 1)
same command, OPENCLAW_DEBUG=1 Reason: + stack: plain Error at the guard (src/cli/models-cli.ts:586) remedy line only, no Reason/stack (expected-error early return)
models auth login --help (control) exit 0, help text exit 0, identical help text

Live runs through the shipped entry point (node --import tsx src/entry.ts ...), both sides on the same isolated profile: OPENCLAW_STATE_DIR and OPENCLAW_CONFIG_PATH point at a scratch directory with an empty config, so no credentials or configuration are written (the conflict guard is the first statement of the action handler). The service-probe warning and the log-append note in the outputs below are artifacts of that isolated profile and appear identically on both sides.

After (this head):

$ node --import tsx src/entry.ts models auth login --device-code --method password
Installed Gateway service state and config paths could not be verified. Inspect the service environment with `openclaw gateway status --deep` before repairing plugin state.
[openclaw] log file append failed; records dropped; check that the path is a writable regular file; file=openclaw-2026-11-13.log
--device-code cannot be combined with --method unless method is device-code.
(exit 1)

Before (base, owner file reverted via git show, test kept):

$ node --import tsx src/entry.ts models auth login --device-code --method password
Installed Gateway service state and config paths could not be verified. Inspect the service environment with `openclaw gateway status --deep` before repairing plugin state.
[openclaw] log file append failed; records dropped; check that the path is a writable regular file; file=openclaw-2026-11-13.log
[openclaw] The CLI command failed.
[openclaw] For help, run `openclaw doctor`.
(exit 1)

Before with OPENCLAW_DEBUG=1 shows the hidden remedy and proves the plain-Error envelope (excerpt, stack path normalized):

[openclaw] The CLI command failed.
[openclaw] Reason: --device-code cannot be combined with --method unless method is device-code.
[openclaw] Stack:
[openclaw] Error: --device-code cannot be combined with --method unless method is device-code.
[openclaw]     at OpenClawCommand.<anonymous> (src/cli/models-cli.ts:586:15)

Unit invariant, same folded test with the owner file swapped: on base the plain Error carries message but no humanOutput, so the guard assertion fails (1 failed | 21 passed); on this head the full file passes (22 passed).

FAIL src/cli/models-cli.test.ts > models cli > maps --device-code to the provider device-code auth method
AssertionError: expected Error: --device-code cannot be combined w… to match object { Object (humanOutput) }
- Expected
+ Received
- {
-   "humanOutput": "--device-code cannot be combined with --method unless method is device-code.",
+ Error {
+   "message": "--device-code cannot be combined with --method unless method is device-code.",
  }

Open PR collision check (submission-day sweep, 2026-11-13): scanned the 60 most recent open PRs plus keyword searches (device-code, throwExpectedCliError, expected-cli-error, failure-output, models auth login) and compared changed-file lists. #190482 and #198294 also touch src/cli/models-cli.ts, but their hunks (fallbacks-list --agent rejection near L422; withModelsRuntime near L38) are disjoint from this import/guard change and merge cleanly; #191233 and #191237 are sibling per-site fixes of the same anti-pattern in security-cli.ts / worktrees-cli.ts; #184579 is a headless device-code feature in the commands layer, not the CLI registration guard. No open PR touches failure-output.ts or expected-cli-error.ts, and the defect is still present on current origin/main.

What was not tested: local lint and typecheck. The repo wrapper rejects this worktree's symlinked node_modules ("Declaration input escapes checkout"), and the direct oxlint binary fails loading the config's JS plugin because the shared install's eslint-plugin-solid peer-hash symlink is stale. Both lanes were attempted; the change is byte-identical to the canonical pattern already compiling on main (the import line matches seven sibling src/cli files; the call shape matches dns-cli.ts), so lint/type verification is left to CI on this head.

The --device-code/--method conflict guard threw a plain Error, which the
root failure renderer collapses to "The CLI command failed." plus a
doctor hint, hiding the remedy. Throw the expected CLI error so the
message is printed directly.

Ref: BUG-308-models-auth-login-device-code-method-hidden (local finding)
@clawsweeper

clawsweeper Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added cli CLI command changes size: XS labels Nov 13, 2026
@SunnyShu0925
SunnyShu0925 marked this pull request as ready for review November 13, 2026 15:19
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: ⏳ waiting on maintainer Only explicit maintainer approvals or decisions remain; merge is still blocked. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Nov 13, 2026
@clawsweeper

clawsweeper Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge.

What this changes

This PR makes conflicting device-code login options display their existing remedy instead of a generic CLI failure.

Example: Run openclaw models auth login --device-code --method password.

  • Before: The command prints a generic failure and suggests running Doctor.
  • After: The command prints --device-code cannot be combined with --method unless method is device-code. and still exits 1.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A useful, minimal repair with direct CLI proof and a focused regression; hosted validation awaits workflow approval.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): The supplied isolated src/entry.ts CLI traces exercise the changed models guard through root rendering and show the remedy replacing generic output with exit 1 preserved.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: An invalid login option combination hides the explanation needed to correct the command.
Reason: The change restores the existing actionable-error contract with minimal production cost and no new product policy.

Merge readiness

⛔ Blocked before merge - 1 item remains

This PR fixes a verified diagnostic bug with a minimal change and credible CLI proof; no actionable patch defects were found.

Priority: P3
Reviewed head: 3a08d5b7444c5b0785c21ae0ebcf48b393ffbb6d

Before merge

Findings

None.

Agent review details

How this fits together

The models CLI validates login arguments before invoking authentication, and the root CLI renderer converts the resulting error into terminal output.

flowchart TD
  A[Login arguments] --> B[Models CLI conflict guard]
  B --> C[Expected CLI error]
  C --> D[Root failure renderer]
  D --> E[Remedy and exit code 1]
Loading

Technical review

Best possible solution:

Use the existing expected-error helper at this guard while retaining the current validation, remedy, and authentication flow.

Do we have a high-confidence way to reproduce the issue?

Current-main source confirms the plain-error guard and generic rendering path; the contributor supplies matching before/after CLI traces, which were reviewed without executing target code.

Is this the best way to solve the issue?

This is the smallest complete fix: classify the existing actionable refusal using the established helper, without widening error disclosure for every models command.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against af10e5594d38.

Provenance checked

  • Device-code conflict validation keeps the original intent (9dedc4d: Support explicit device-code login while rejecting a conflicting method selection.)
  • Expected CLI error rendering keeps the original intent (bc097bf: Expose specific input remedies through a dependency-light expected-error owner while retaining root rendering ownership; older renderer blame is locally unavailable because historical blobs are missing.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 9dedc4d adds src/cli/models-cli.ts:340 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 9dedc4d95cfb; files: src/cli/models-cli.ts)

PR surface

Source +1, Tests 0. Total +1 across 2 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 2 1 +1
Tests 1 4 4 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 6 5 +1

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Labels

Label changes:

No label changes.

Label justifications:

  • P3: This is a focused diagnostic improvement for an invalid combination of advanced CLI options.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: ⏳ waiting on maintainer: Only explicit maintainer approvals or decisions remain; merge is still blocked.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed November 13, 2026, 10:35 AM ET / 15:35 UTC.

@obviyus

obviyus commented Nov 16, 2026

Copy link
Copy Markdown
Collaborator

Thanks for the work here. We're closing this one along with the other open per-command --json error fixes. These PRs all fix the same root cause one command at a time: runCommandWithRuntime rethrows plain errors in JSON mode, so the root renderer prints the generic failure instead of the existing message. We're fixing that once in the shared wrapper instead, which covers this command too. Please don't open more per-command variants of this fix; if you find a case the shared fix doesn't cover, open an issue with a reproduction.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clawtributors PR from a clawtributor cli CLI command changes P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XS status: ⏳ waiting on maintainer Only explicit maintainer approvals or decisions remain; merge is still blocked.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants