{"record":{"id":"695e246792e32c6e","repo":"thedotmack/claude-mem","slug":"api-key-prompt-cancelled-falling-back-to-claude","errorCode":null,"errorMessage":"API key prompt cancelled — falling back to Claude provider.","messagePattern":"API key prompt cancelled — falling back to Claude provider\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/npx-cli/commands/install.ts","lineNumber":1223,"sourceCode":"    && isCmemGatewayUrl(existingOpenRouterBaseUrl);\n  if (existingKey && existingKey.trim().length > 0 && !existingKeyIsCmem) {\n    const wrote = mergeSettings({ CLAUDE_MEM_PROVIDER: selectedProvider });\n    if (wrote) log.info(`Saved provider=${selectedProvider} to ~/.claude-mem/settings.json`);\n    return selectedProvider;\n  }\n\n  if (!isInteractive) {\n    throw new Error(`Non-interactive ${providerLabel} configuration is missing a personal API key.`);\n  }\n\n  const apiKeyResult = await p.password({\n    message: `Paste your ${providerLabel} API key:`,\n    mask: '*',\n    validate: (v?: string) => (!v || v.trim().length === 0) ? 'API key required' : undefined,\n  });\n\n  if (p.isCancel(apiKeyResult)) {\n    log.warn(`API key prompt cancelled — falling back to Claude provider.`);\n    persistClaudeProvider();\n    return 'claude';\n  }\n\n  const apiKey = String(apiKeyResult).trim();\n  const updates = selectedProvider === 'openrouter'\n    ? buildPersonalOpenRouterSettings(\n      apiKey,\n      readPersistedInstallerSettings(),\n      SettingsDefaultsManager.getAllDefaults().CLAUDE_MEM_OPENROUTER_MODEL,\n    )\n    : {\n      CLAUDE_MEM_PROVIDER: selectedProvider,\n      [keyEnvName]: apiKey,\n    };\n  const wrote = mergeSettings(updates);\n  if (wrote) {\n    log.info(`Saved provider=${selectedProvider} to ~/.claude-mem/settings.json`);","sourceCodeStart":1205,"sourceCodeEnd":1241,"githubUrl":"https://github.com/thedotmack/claude-mem/blob/d8bc9755e74915e5c3b999181e10a67c889bce2a/src/npx-cli/commands/install.ts#L1205-L1241","documentation":"In the interactive provider-setup flow, if the user cancels (Ctrl-C / Esc) the masked API key prompt, the installer does not abort. Instead it warns, persists the default 'claude' provider via persistClaudeProvider(), and returns 'claude' as the selected provider.","triggerScenarios":"User selects a BYO-key provider (OpenRouter, etc.), is shown the `message: 'Paste your <provider> API key:'` prompt, and cancels it via p.isCancel — non-TTY or interrupt.","commonSituations":"User doesn't have the key handy and presses Esc/Ctrl-C; aborted prompt in a partially automated terminal; accidental interrupt.","solutions":["Rerun `npx claude-mem install` (or the provider setup) and paste the API key when prompted.","Accept the Claude provider fallback if you want to use Anthropic via Claude subscription instead of a custom key.","Manually update the provider settings (e.g. via claude-mem settings) later once the key is available."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"if (!process.stdin.isTTY) {\n  console.warn('API key prompt requires a TTY; provider will fall back to claude.');\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Have the provider API key ready in your clipboard before starting install.","Run the installer in a real interactive terminal, not a piped/non-TTY context.","Avoid pressing Esc/Ctrl-C at the masked prompt; to change provider later, rerun setup or edit settings."],"tags":["interactive-prompt","api-key","provider","fallback"],"backgroundTag":"user-cancelled-input","analyzedSha":"d8bc9755e74915e5c3b999181e10a67c889bce2a","analyzedAt":"2026-09-17T16:40:26.182Z","contentChangedAt":"2026-09-17T16:40:26.182Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}