Skip to content

fix: guard clack cancel symbol in models auth CLI prompts#38951

Closed
MumuTW wants to merge 1 commit intoopenclaw:mainfrom
MumuTW:fix/setup-wizard-cancel-token
Closed

fix: guard clack cancel symbol in models auth CLI prompts#38951
MumuTW wants to merge 1 commit intoopenclaw:mainfrom
MumuTW:fix/setup-wizard-cancel-token

Conversation

@MumuTW
Copy link
Copy Markdown
Contributor

@MumuTW MumuTW commented Mar 7, 2026

Summary

  • When user cancels a manual token prompt (Ctrl+C / Escape) in openclaw models auth commands, the @clack/prompts cancel symbol was coerced to the string "Symbol(clack:cancel)" and persisted as the token value in auth-profiles.json, causing 401 errors when the profile was later selected as a fallback.
  • Added isCancel guard to the local text / select / confirm wrappers in src/commands/models/auth.ts so cancellation exits cleanly via process.exit(0) instead of persisting a bogus token.

Closes #38928

Test plan

  • Run openclaw models auth paste-token --provider openai, press Escape or Ctrl+C at the token prompt — verify the process exits without writing to auth-profiles.json
  • Run openclaw models auth add, cancel at any prompt — verify clean exit
  • Run openclaw models auth setup-token, cancel at confirm or token prompt — verify clean exit
  • Normal token entry still works and persists correctly

When user cancels a manual token prompt (Ctrl+C/Escape) in
`openclaw models auth` commands, the clack cancel symbol was
coerced to "Symbol(clack:cancel)" and persisted as the token
value in auth-profiles.json. This caused 401 errors when the
profile was later used as a fallback.

Add isCancel guard to the local text/select/confirm wrappers
so cancellation exits cleanly instead of persisting a bogus token.

Closes openclaw#38928
@openclaw-barnacle openclaw-barnacle bot added commands Command implementations size: S labels Mar 7, 2026
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Mar 7, 2026

Greptile Summary

This PR fixes a bug where pressing Ctrl+C or Escape during a @clack/prompts interactive prompt in models auth commands caused the library's cancel symbol to be coerced to the string "Symbol(clack:cancel)" and written to auth-profiles.json, resulting in 401 errors on subsequent use. The fix introduces a guardCancel<T> helper that checks isCancel(value), prints a "Cancelled." message, and calls process.exit(0) before the bogus value can propagate. All three local prompt wrappers (confirm, text, select) are updated to async functions that pass their results through guardCancel.

Key changes:

  • New guardCancel<T>(value: T | symbol): T function using isCancel from @clack/prompts for clean cancellation handling.
  • confirm, text, and select wrappers made async and wrapped with guardCancel.
  • Removed now-unnecessary explicit as TokenProvider | "custom" cast for provider in modelsAuthAddCommand — TypeScript correctly infers "anthropic" | "custom" from the options literals.
  • The modelsAuthLoginCommand code path uses a separate createClackPrompter() abstraction (prompter.select) and is outside the scope of this fix; whether it handles cancellation is a separate concern.

Confidence Score: 5/5

  • This PR is safe to merge — it is a targeted bug fix with no regressions and correct TypeScript typing.
  • The change is minimal and well-scoped: a single guardCancel helper is added and applied consistently to all three local prompt wrappers. The process.exit(0) path after cancel() is the idiomatic clack pattern. TypeScript typing is preserved (inference for provider is equivalent to the removed explicit cast). No new external dependencies or side-effects are introduced beyond those already present. The fix directly addresses the root cause described in the issue.
  • No files require special attention.

Last reviewed commit: 8bc215e

@steipete
Copy link
Copy Markdown
Contributor

steipete commented Mar 7, 2026

Landed. Thank you @MumuTW.

What I did:

  • rebased onto latest main via a temp landing branch
  • kept the cancel-guard fix and hardened it to treat symbol values as cancel
  • added regression test coverage in src/commands/models/auth.test.ts to prevent cancelled token persistence
  • added changelog entry under 2026.3.7 fixes mentioning fix: guard clack cancel symbol in models auth CLI prompts #38951 and @MumuTW
  • ran full gate before commit: pnpm lint && pnpm build && pnpm test
  • landed to main with co-author trailer

SHA hashes:

  • original PR commit: 8bc215e6d5dc
  • landed commit on main: 2ada1b71b

Thanks again for the fix.

@steipete steipete closed this Mar 7, 2026
mrosmarin added a commit to mrosmarin/openclaw that referenced this pull request Mar 7, 2026
* main: (133 commits)
  reduce image size, offer slim image (openclaw#38479)
  fix(security): harden install base drift cleanup
  fix(agents): respect explicit provider baseUrl in merge mode (openclaw#39103)
  fix(agents): apply contextTokens cap for compaction threshold (openclaw#39099)
  fix(exec): block dangerous override-only env pivots
  fix(security): stage installs before publish
  fix(daemon): normalise whitespace in checkTokenDrift to prevent false-positive warning (openclaw#39108)
  fix(security): harden fs-safe copy writes
  refactor: dedupe bluebubbles webhook auth test setup
  refactor: dedupe discord native command test scaffolding
  refactor: dedupe anthropic probe target test setup
  refactor: dedupe minimax provider auth test setup
  refactor: dedupe runtime snapshot test fixtures
  fix: harden zip extraction writes
  fix(tests): stabilize diffs localReq headers (supersedes openclaw#39063)
  fix: harden workspace skill path containment
  fix(agents): land openclaw#38935 from @MumuTW
  fix(models): land openclaw#38947 from @davidemanuelDEV
  fix(gateway): land openclaw#39064 from @Narcooo
  fix(models-auth): land openclaw#38951 from @MumuTW
  ...
vincentkoc pushed a commit to BryanTegomoh/openclaw-fork that referenced this pull request Mar 8, 2026
openperf pushed a commit to openperf/moltbot that referenced this pull request Mar 8, 2026
mcaxtr pushed a commit to mcaxtr/openclaw that referenced this pull request Mar 8, 2026
Saitop pushed a commit to NomiciAI/openclaw that referenced this pull request Mar 8, 2026
GordonSH-oss pushed a commit to GordonSH-oss/openclaw that referenced this pull request Mar 9, 2026
jenawant pushed a commit to jenawant/openclaw that referenced this pull request Mar 10, 2026
dhoman pushed a commit to dhoman/chrono-claw that referenced this pull request Mar 11, 2026
senw-developers pushed a commit to senw-developers/va-openclaw that referenced this pull request Mar 17, 2026
V-Gutierrez pushed a commit to V-Gutierrez/openclaw-vendor that referenced this pull request Mar 17, 2026
alexey-pelykh pushed a commit to remoteclaw/remoteclaw that referenced this pull request Mar 20, 2026
Co-authored-by: MumuTW <[email protected]>
(cherry picked from commit 2ada1b7)
alexey-pelykh pushed a commit to remoteclaw/remoteclaw that referenced this pull request Mar 20, 2026
Co-authored-by: MumuTW <[email protected]>
(cherry picked from commit 2ada1b7)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commands Command implementations size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Setup wizard persists Symbol(clack:cancel) as token when user cancels manual token entry

2 participants