Skip to content

fix(auth): name the provider and remedy in request-time credential errors; accept GOOGLE_API_KEY (OB3) - #137

Merged
lg2m merged 2 commits into
mainfrom
fix/eng-877-request-credential-errors
Sep 23, 2026
Merged

lg2m merged 2 commits into
mainfrom
fix/eng-877-request-credential-errors

Conversation

@lg2m

@lg2m lg2m commented Sep 23, 2026

Copy link
Copy Markdown
Collaborator

OB3: request-time credential errors name the provider and remedy; accept GOOGLE_API_KEY

Spec: docs/plans/onboarding-ux.md#ob3 Linear: ENG-877 (parent ENG-875)

What changes for users

Before → after:

  • xai, nothing stored: provider response failed: request credentials are missing → …: no credential for provider `xai`: run `qq auth login xai --oauth` or `qq auth login xai` or set the environment variable `XAI_API_KEY`
  • codex: → no credential for provider `openai-codex`: run `qq auth login openai-codex`
  • missing named profile: credential `xai/work` is not registered: run `qq auth login xai --oauth --profile work` or …
  • secret gone from keyring: credential `xai/default` is registered, but its secret is missing: run `qq auth logout xai/default`, then …
  • google: GOOGLE_API_KEY now works as an alias of GEMINI_API_KEY (precedence GEMINI then GOOGLE); the missing-credential message lists both.
  • Explicit Env(...) / foreign Stored(...) references keep their own message (the provider remedy would describe the wrong credential).

Design

  • RequestCredentialError::Missing { remedy: Option<Arc<str>> }; Display falls back to the old text; ProviderErrorKind::Authentication mapping unchanged. Remedy text is authored once in qq-auth (MissingCredentialRemedies) when the request-credential provider is constructed; qq-provider treats it as opaque. No per-request allocation; provider identity does not branch on the request path.
  • resolve_provider_credential_with_aliases (old fn delegates with &[]); HttpCredential::ApiKey.alternate_variables: &'static [&'static str]; google preset = &["GOOGLE_API_KEY"]. Descriptor digest still names GEMINI_API_KEY, independent of spelling.

How verified

  • fmt, clippy, cargo test --workspace, and cargo test -p qq-provider --no-default-features --features test-support.
  • qq-provider (3, both profiles): remedy display vs fallback; kind mapping; authorize() surfaces the remedy. qq-auth (8): xai nothing-stored / named profile / secret-missing / explicit Env keeps own message; codex nothing-stored / --profile work; google alias message; alias precedence via injected lookup. qq bin: provider_authenticated("google") + plan_for succeed with only GOOGLE_API_KEY (child process with env_clear() — the test binary shares process env and set_var is unsafe in edition 2024).
  • Manual with empty XDG_CONFIG_HOME: each message above reproduced verbatim. GOOGLE_API_KEY=x with a google model passes credential resolution and then fails at Google with HTTP 400 Unknown name "additionalProperties" at 'tools[0].function_declarations[0].parameters' — pre-existing and unrelated; filed as a follow-up below.

Docs

docs/guide/troubleshooting.md, providers.md, configuration.md, quickstart.md; ledger.

Compatibility

RequestCredentialError drops Copy (public type in qq-provider; additive field). AuthError::ProviderCredentialMissing gains alternate_variables. No protocol/schema change.

Follow-ups

  • Gemini rejects additionalProperties in tool schemas (needs its own issue).
  • xtask/src/providers.rs canary still uses GEMINI_API_KEY only — fine, out of scope.

…rors

OB3 / ENG-877.

`RequestCredentialError::Missing` now carries an optional `Arc<str>` remedy.
qq-auth authors the text once when it constructs the xAI and Codex
request-credential providers and attaches it when mapping
`ProviderCredentialMissing`, `StoredCredentialNotRegistered`, and
`StoredCredentialMissing`; qq-provider displays it opaquely, keeps the old
`request credentials are missing` text when none is attached, and still
classifies the failure as `Authentication`. The request hot path clones one
`Arc` on the error path only.

A run on `xai/...` with nothing stored now fails with
  no credential for provider `xai`: run `qq auth login xai --oauth` or
  `qq auth login xai` or set the environment variable `XAI_API_KEY`
and on `openai-codex/...` with
  no credential for provider `openai-codex`: run `qq auth login openai-codex`.
A configured profile is named with `--profile`, and a registered entry whose
secret is gone suggests `qq auth logout NAME` first.

`GOOGLE_API_KEY` is accepted as an alias of `GEMINI_API_KEY`
(`GEMINI_API_KEY` wins). `HttpCredential::ApiKey` gained
`alternate_variables`; `resolve_provider_credential_with_aliases` walks them
and the plan-time message lists both. The plan descriptor still records
`GEMINI_API_KEY` so the digest does not depend on the spelling.

`SharedRequestCredentialProvider` now implements
`RequestCredentialProvider` so tests can drive the shared handle.

Tests: qq-provider (both feature profiles) for remedy display and kind
mapping; qq-auth for xAI/Codex/profile/secret-missing/explicit-reference
messages and alias precedence; bin child-process test for
`provider_authenticated` with only `GOOGLE_API_KEY`.
…_KEY

OB3 / ENG-877. Troubleshooting replaces the `request credentials are
missing` entry with the new provider-named messages; providers,
configuration, and quickstart list `GEMINI_API_KEY` or `GOOGLE_API_KEY`.
Ledger: OB3 to In review.
@lg2m
lg2m force-pushed the fix/eng-877-request-credential-errors branch from ec68782 to 7df7996 Compare September 23, 2026 04:04
@lg2m
lg2m merged commit 0dc3ef6 into main Sep 23, 2026
4 checks passed
@lg2m
lg2m deleted the fix/eng-877-request-credential-errors branch September 23, 2026 04:08
lg2m added a commit that referenced this pull request Sep 23, 2026
OB3 (#137) made GOOGLE_API_KEY an alias of GEMINI_API_KEY; the doctor's
credential check now reads HttpCredential::ApiKey.alternate_variables,
accepts any of them as authenticating, and writes the remedy as
`set GEMINI_API_KEY (or GOOGLE_API_KEY)`. Closes the OB3→OB4 follow-up
named in #138 (OB4, ENG-878).
lg2m added a commit that referenced this pull request Sep 23, 2026
* feat(cli): add qq doctor readiness report with per-check remedies

One screen that says whether QQ is ready to run here: configuration,
project trust, model, credential for the model's provider, credential
store, server discovery, workspace, and data directory. Each line is
ok/warn/fail/skip with the remedy indented beneath anything not ok.
Exit 0 when nothing fails, 1 otherwise; `--json` for scripts.

`src/doctor.rs` keeps `run_checks` free of I/O to stdout so the text and
JSON renderers and the tests share one report. The credential check
mirrors `RuntimeFactory::provider_authenticated`; the AWS chain helpers in
`runtime.rs` are now `pub(crate)` and shared rather than duplicated. No
provider is contacted; the keyring is exercised only through the model's
stored credential, never probed blindly.

Slice OB4 of docs/plans/onboarding-ux.md. ENG-878.

* docs(guide): document qq doctor and point troubleshooting at it first

CLI reference section for `qq doctor [--json]` with the check table;
troubleshooting opens with a sample report; quickstart and the guide index
mention it. Ledger: OB4 to In review.

Slice OB4. ENG-878.

* feat(cli): name GOOGLE_API_KEY in the doctor's google remedy

OB3 (#137) made GOOGLE_API_KEY an alias of GEMINI_API_KEY; the doctor's
credential check now reads HttpCredential::ApiKey.alternate_variables,
accepts any of them as authenticating, and writes the remedy as
`set GEMINI_API_KEY (or GOOGLE_API_KEY)`. Closes the OB3→OB4 follow-up
named in #138 (OB4, ENG-878).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant