Skip to content

fix(errors): simplify auth error message when API key is missing#32170

Closed
ademczuk wants to merge 4 commits intoopenclaw:mainfrom
ademczuk:fix/auth-error-message-ux
Closed

fix(errors): simplify auth error message when API key is missing#32170
ademczuk wants to merge 4 commits intoopenclaw:mainfrom
ademczuk:fix/auth-error-message-ux

Conversation

@ademczuk
Copy link
Copy Markdown
Contributor

@ademczuk ademczuk commented Mar 2, 2026

Summary

Before

⚠️ Agent failed before reply: No API key found for provider "google".
Auth store: /home/user/.openclaw/agents/main/agent/auth-profiles.json
(agentDir: /home/user/.openclaw/agents/main/agent). Configure auth for
this agent (openclaw agents add <id>) or copy auth-profiles.json from
the main agentDir.

After

⚠️ Agent failed before reply: No API key found for provider "google".
Set GEMINI_API_KEY or run openclaw auth add google to configure it.

Test plan

  • All 151 affected tests pass (model-auth, model-fallback, agent-runner, embeddings, error classification)
  • pnpm check — zero lint errors
  • Error classification ("no api key found" substring match) still works
  • Single-model failures show clean message directly (re-thrown by model-fallback)
  • Multi-model failures remain readable when joined with |
  • Manual test: /model → select unconfigured provider → verify clear error message

cc @vincentkoc for review

🤖 Generated with Claude Code

@openclaw-barnacle openclaw-barnacle bot added agents Agent runtime and tooling size: S labels Mar 2, 2026
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 38a7c8ae2e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Mar 2, 2026

Greptile Summary

Simplified API key error messages by replacing technical details (auth store paths, agentDir) with clear, actionable instructions. When an API key is missing, users now see which environment variable to set and what command to run, rather than internal file paths.

  • Extracted PROVIDER_ENV_MAP constant to eliminate duplication between resolveEnvApiKey() and the new getEnvVarHint() helper function
  • New error format provides environment variable name (e.g., GEMINI_API_KEY) and suggests running openclaw auth add <provider> to configure it
  • Handles edge cases correctly: providers without env vars (like google-vertex using gcloud adc) show command-only instruction
  • All 151 affected tests pass, error classification (substring match on "no api key found") continues to work correctly

Confidence Score: 5/5

  • This PR is safe to merge with no risk
  • Clean refactoring with improved UX that maintains all existing functionality. The change extracts a shared constant to eliminate duplication, simplifies error messages for better user experience, and includes comprehensive test coverage. No logic changes affect the authentication flow - only the error message formatting is improved. All tests pass and error classification remains functional.
  • No files require special attention

Last reviewed commit: 38a7c8a

@ademczuk
Copy link
Copy Markdown
Contributor Author

ademczuk commented Mar 2, 2026

Good catch — fixed in 78bfd4e. The command is now openclaw models auth add (the interactive auth wizard registered at src/cli/models-cli.ts:298).

The original error had the same issue (openclaw agents add <id> manages workspace agents, not API keys).

@ademczuk ademczuk force-pushed the fix/auth-error-message-ux branch from 78bfd4e to a9433a8 Compare March 2, 2026 21:42
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a9433a8b56

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@ademczuk
Copy link
Copy Markdown
Contributor Author

ademczuk commented Mar 2, 2026

Addressed Codex P2 ("Use agent-scoped guidance in missing-key hint") in 5924c21:

When resolveApiKeyForProvider is called with a non-default agentDir, the error now appends (agent auth store: <path>) so users in multi-agent setups know which store needs credentials.

@ademczuk
Copy link
Copy Markdown
Contributor Author

ademczuk commented Mar 2, 2026

CI failures: pre-existing upstream issues (not from this PR)

Both check and secrets failures affect all open PRs, not just this one:

1. checkChannelKind import (TS2305)

Upstream commit 55a2d12f40 ("refactor: split inbound and reload pipelines into staged modules") moved ChannelKind out of config-reload.ts into config-reload-plan.ts, but server-reload-handlers.ts:20 still imports from the old location.

Fix: Update the import in src/gateway/server-reload-handlers.ts:

-import type { ChannelKind, GatewayReloadPlan } from "./config-reload.js";
+import type { ChannelKind } from "./config-reload-plan.js";
+import type { GatewayReloadPlan } from "./config-reload.js";

2. checkThreadType enum as type (TS2749)

Upstream commit f9025c3f55 ("feat(zalouser): add reactions, group context, and receipt acks") introduced ApiTypingCapability in extensions/zalouser/src/zalo-js.ts:67 using bare ThreadType in type position, which tsgo rejects.

Fix: Use (typeof ThreadType)[keyof typeof ThreadType] instead of bare ThreadType in the type alias.

3. secrets — npm audit (11 advisories)

extensions__googlechat>openclaw requires >=2026.3.1. Not actionable from any PR branch — requires a new release or an audit allowlist.


PR #32128 includes fixes for issues 1 and 2. Once those land (or main is patched directly), both PRs should go green on check.

@ademczuk ademczuk force-pushed the fix/auth-error-message-ux branch 2 times, most recently from f4bbf93 to cc60f43 Compare March 2, 2026 22:57
ademczuk and others added 4 commits March 3, 2026 00:35
When resolveApiKeyForProvider is called with a non-default agentDir,
the error now appends the agent-specific auth store path so users
know which store needs credentials in multi-agent setups.

Addresses Codex P2: "Use agent-scoped guidance in missing-key hint".

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@ademczuk ademczuk force-pushed the fix/auth-error-message-ux branch from cc60f43 to a1bb45d Compare March 2, 2026 23:36
@ademczuk
Copy link
Copy Markdown
Contributor Author

ademczuk commented Mar 2, 2026

Looks like Peter already fixed it. Commit 0e16749 landed on main — fixes both the pairing-store.ts lint errors, the agents-utils.ts lint error, AND bumps the googlechat/memory-core deps (npm audit fix).

Both issues are already resolved on main.

Please take a look at this @Takhoffman at your leisure.

@steipete
Copy link
Copy Markdown
Contributor

steipete commented Mar 2, 2026

Thanks for the PR! Multiple PRs address issue #31544 (missing API key guidance). Keeping #31554 as the earliest submission. Closing to reduce noise. This is an AI-assisted triage review. If we got this wrong, feel free to reopen — happy to revisit.

@steipete steipete closed this Mar 2, 2026
@ademczuk ademczuk deleted the fix/auth-error-message-ux branch March 6, 2026 07:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Warning Message When Selecting a Model with API KEY Not Configured is Not Helpful

2 participants