openclaw - 💡(How to fix) Fix openclaw update: completion cache refresh fails because onboard gets duplicate --openai-api-key registration [2 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#71667Fetched 2026-04-26 05:10:00
View on GitHub
Comments
2
Participants
2
Timeline
3
Reactions
0
Author
Participants
Timeline (top)
commented ×2closed ×1

Error Message

Completion cache update failed ([openclaw] Failed to start CLI: Error: Cannot add option '--openai-api-key <key>' to command 'onboard' due to conflicting flag '--openai-api-key'

Root Cause

  • CLI startup fails during completion refresh
  • Commander throws because onboard receives duplicate registration of --openai-api-key
  • update looks stuck/broken to the user

Code Example

Completion cache update failed ([openclaw] Failed to start CLI: Error: Cannot add option '--openai-api-key <key>' to command 'onboard' due to conflicting flag '--openai-api-key'

---

function hasLongFlag(command: Command, longFlag: string): boolean {
  return command.options.some(opt =>
    opt.long === longFlag ||
    opt.flags.includes(longFlag)
  );
}

function addOptionOnce(command: Command, option: Option) {
  if (hasLongFlag(command, option.long)) return;
  command.addOption(option);
}
RAW_BUFFERClick to expand / collapse

Bug

openclaw update fails at the final completion-cache refresh step with:

Completion cache update failed ([openclaw] Failed to start CLI: Error: Cannot add option '--openai-api-key <key>' to command 'onboard' due to conflicting flag '--openai-api-key'

What I checked

  • openclaw --help still works, so this does not look like a general CLI boot failure
  • the failure appears specific to the onboard command path during completion refresh
  • a quick search through the obvious packaged entry points did not show simple top-level hardcoded matches for either:
    • openai-api-key
    • onboard

That makes a dynamic/generated option-registration path more likely than a single duplicated inline .option('--openai-api-key ...') in a top-level file.

Expected

  • openclaw update completes cleanly
  • completion cache refresh succeeds
  • onboard option registration is idempotent

Actual

  • CLI startup fails during completion refresh
  • Commander throws because onboard receives duplicate registration of --openai-api-key
  • update looks stuck/broken to the user

Likely root cause

Probably one of:

  1. onboard has a static OpenAI flag and a provider/auth injector adds it again
  2. onboarding/provider option builders run twice during completion-cache refresh
  3. completion generation rebuilds the command tree and re-runs side-effectful registration
  4. dynamically generated provider flags are not deduped before addOption()

Proposed fix

Defensive fix

Make onboarding/provider option registration idempotent:

function hasLongFlag(command: Command, longFlag: string): boolean {
  return command.options.some(opt =>
    opt.long === longFlag ||
    opt.flags.includes(longFlag)
  );
}

function addOptionOnce(command: Command, option: Option) {
  if (hasLongFlag(command, option.long)) return;
  command.addOption(option);
}

Structural fix

Centralize onboard option assembly so it only runs once per command instance, or dedupe the final option set before registration.

UX fix

If completion refresh fails, openclaw update should fail soft:

  • warn
  • exit cleanly
  • say the update succeeded but completion refresh failed

Environment

  • Platform: Windows
  • Trigger: openclaw update
  • Observed around: 2026.4.25

extent analysis

TL;DR

Implementing an idempotent option registration for the onboard command, such as using the proposed addOptionOnce function, is likely to fix the completion cache refresh failure.

Guidance

  • Verify that the onboard command's option registration is indeed the cause of the failure by checking the command's options and flags.
  • Consider implementing the proposed addOptionOnce function to make option registration idempotent.
  • If the issue persists, investigate the possibility of duplicate option registrations due to dynamic generation or rebuilding of the command tree.
  • To mitigate the issue, consider implementing a soft failure for openclaw update when completion refresh fails, providing a warning and a clean exit.

Example

function addOptionOnce(command: Command, option: Option) {
  if (hasLongFlag(command, option.long)) return;
  command.addOption(option);
}

This example illustrates how to make option registration idempotent, preventing duplicate registrations.

Notes

The proposed fix assumes that the issue is due to duplicate option registrations. If the issue is caused by a different factor, additional investigation may be necessary.

Recommendation

Apply the proposed addOptionOnce function as a workaround to make option registration idempotent, as it is a relatively simple and non-invasive change that can help resolve the issue.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - 💡(How to fix) Fix openclaw update: completion cache refresh fails because onboard gets duplicate --openai-api-key registration [2 comments, 2 participants]