Skip to content

Suggest CLI providers when API key is missing#91

Merged
Miyamura80 merged 2 commits intomasterfrom
improve/suggest-cli-providers-on-missing-api-key
Mar 31, 2026
Merged

Suggest CLI providers when API key is missing#91
Miyamura80 merged 2 commits intomasterfrom
improve/suggest-cli-providers-on-missing-api-key

Conversation

@Miyamura80
Copy link
Copy Markdown
Contributor

@Miyamura80 Miyamura80 commented Mar 31, 2026

Summary

  • When no API key is configured, the error message now suggests using --provider claude-cli or --provider codex-cli as alternatives that don't require an API key
  • Applies to both provider-specific and generic error paths in resolve_api_key_with_source()

Test plan

  • Run desktest run task.json without any API key set and verify the tip appears
  • Run desktest run task.json --provider claude-cli and verify no API key error

🤖 Generated with Claude Code


Open with Devin

When no API key is configured, the error message now hints that
users can use --provider claude-cli or --provider codex-cli to
run without an API key.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Open in Devin Review

@greptile-apps
Copy link
Copy Markdown

greptile-apps bot commented Mar 31, 2026

Greptile Summary

This PR improves the developer experience when running desktest without an API key configured. It augments the error message returned by resolve_api_key_with_source() in both the provider-specific and generic error branches to add a tip pointing users toward --provider claude-cli or --provider codex-cli as zero-API-key alternatives.

Key observations:

  • The change is minimal and isolated to the error-message construction in resolve_api_key_with_source()
  • The Rust line-continuation escape (\ \\ + indented next line) is used correctly — leading whitespace on the continuation line is stripped, so the resulting string is properly formatted as two lines separated by a single newline
  • CLI providers (claude-cli, codex-cli) are short-circuited in create_provider() before resolve_api_key() is ever called, so the tip will never be shown redundantly to a user already targeting a CLI provider
  • In preflight.rs the same guard exists (lines 350–353 check for CLI providers before falling into the else branch that calls resolve_api_key_with_source()), so the new tip will also surface correctly in the desktest doctor output

Confidence Score: 5/5

Safe to merge — the change only extends an error message string and has no impact on runtime behavior or control flow

The diff touches only two string literals inside the error path of resolve_api_key_with_source(). The Rust line-continuation escapes are used correctly, CLI providers are properly excluded from this code path both in create_provider() and in preflight.rs, and no logic, data structures, or public API contracts are altered.

No files require special attention

Important Files Changed

Filename Overview
src/provider/mod.rs Appends a CLI-provider tip to both branches of the 'no API key found' error in resolve_api_key_with_source(); change is correct and CLI providers are safely gated before this path is reached

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[create_provider called] --> B{provider == claude-cli\nor codex-cli?}
    B -- Yes --> C[Return CLI provider\nno API key needed]
    B -- No --> D[resolve_api_key called]
    D --> E{explicit_key\nnon-empty?}
    E -- Yes --> F[Return explicit key]
    E -- No --> G{provider_env\nvar set?}
    G -- Yes --> H[Return env key]
    G -- No --> I{LLM_API_KEY\nset?}
    I -- Yes --> J[Return LLM_API_KEY]
    I -- No --> K[Build error hint]
    K --> L{provider_env\nempty?}
    L -- Yes --> M["No API key found...\nTip: use --provider claude-cli or --provider codex-cli"]
    L -- No --> N["No API key found... {provider_env}\nTip: use --provider claude-cli or --provider codex-cli"]
    M --> O[Err AppError::Config]
    N --> O
Loading

Reviews (1): Last reviewed commit: "improve: suggest CLI providers when API ..." | Re-trigger Greptile

Apply rustfmt to orchestration.rs and increase timeout for the
flaky send_request_cleans_up_request_and_response_files test from
10s to 30s to handle slow CI runners.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@Miyamura80 Miyamura80 merged commit 53bcd16 into master Mar 31, 2026
4 checks passed
@Miyamura80 Miyamura80 deleted the improve/suggest-cli-providers-on-missing-api-key branch March 31, 2026 14:11
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