Repository navigation
fix(models): surface the auth login device-code conflict remedy - #198333
SunnyShu0925 wants to merge 1 commit into
Conversation
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)
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: blocked before merge. What this changesThis PR makes conflicting device-code login options display their existing remedy instead of a generic CLI failure. Example: Run
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete 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 Before merge
FindingsNone. Agent review detailsHow this fits togetherThe 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]
Technical reviewBest 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
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +1, Tests 0. Total +1 across 2 files. Added test files: 0. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. LabelsLabel changes: No label changes. Label justifications:
Rating scale6/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. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed November 13, 2026, 10:35 AM ET / 15:35 UTC. |
|
Thanks for the work here. We're closing this one along with the other open per-command |
What Problem This Solves
openclaw models auth login --device-code --method passwordrejects 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.models auth loginaction throws a plainError. The root failure renderer printshumanOutputonly for expected CLI errors, andmodelsis not on the show-reason whitelist, so the message collapses to the generic failure title plusFor help, run openclaw doctor.throw new Error(...)with the canonicalthrowExpectedCliError(...)fromsrc/cli/expected-cli-error.ts, keeping the message verbatim.src/cli/models-cli.ts(one import, one throw) and a regression assertion folded into the existing--device-codemapping test insrc/cli/models-cli.test.ts(net 0 test lines, no new test file).Why This Change Was Made
The renderer already owns the remedy-printing contract: an expected CLI error carries
humanOutput, andformatCliFailureLinesprints it verbatim before any generic fallback. ReusingthrowExpectedCliErroris the established per-site remedy for this exact anti-pattern — the dns CLI fix #192127 adopted the same shape, including therejects.toMatchObject({ humanOutput })guard-test form reused here. Alternatives considered and rejected: addingmodelsto the show-reason whitelist would widen reason printing for every models failure (a larger blast radius than this one guard), and constructingExpectedCliErrorinline 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-codewith an incompatible--methodnow 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
models auth login --device-code --method passwordOPENCLAW_DEBUG=1Reason:+ stack: plainErrorat the guard (src/cli/models-cli.ts:586)models auth login --help(control)Live runs through the shipped entry point (
node --import tsx src/entry.ts ...), both sides on the same isolated profile:OPENCLAW_STATE_DIRandOPENCLAW_CONFIG_PATHpoint 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):
Before (base, owner file reverted via
git show, test kept):Before with
OPENCLAW_DEBUG=1shows the hidden remedy and proves the plain-Error envelope (excerpt, stack path normalized):Unit invariant, same folded test with the owner file swapped: on base the plain Error carries
messagebut nohumanOutput, so the guard assertion fails (1 failed | 21 passed); on this head the full file passes (22 passed).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 touchsrc/cli/models-cli.ts, but their hunks (fallbacks-list--agentrejection near L422;withModelsRuntimenear L38) are disjoint from this import/guard change and merge cleanly; #191233 and #191237 are sibling per-site fixes of the same anti-pattern insecurity-cli.ts/worktrees-cli.ts; #184579 is a headless device-code feature in the commands layer, not the CLI registration guard. No open PR touchesfailure-output.tsorexpected-cli-error.ts, and the defect is still present on currentorigin/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'seslint-plugin-solidpeer-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 siblingsrc/clifiles; the call shape matchesdns-cli.ts), so lint/type verification is left to CI on this head.