Skip to content

CLI silently defaults to OpenAI when no AI provider is configured, then fails with a misleading 'OpenAI API key not configured' message #229

Description

@rafeegnash

Problem

NewClient's default branch silently sets client.provider = "openai" when no provider is specified. A brand-new user who never ran config init then hits 'OpenAI API key not configured (or run clanker auth login for OAuth)' — an OpenAI-specific error for a provider they never chose, with no hint that nothing is configured and that clanker config init is the fix. This is a UX/error-message quality issue, not a functional defect.

Where

  • internal/ai/client.go:574-578
  • internal/ai/client.go:1219

Root cause

The 'no provider selected' state is collapsed into provider=openai at construction, so downstream errors cannot distinguish 'OpenAI chosen, key missing' from 'nothing configured at all'.

How to fix

Detect the genuinely-unconfigured case (no provider and no keys in viper/env) and emit a first-run-aware message naming clanker config init, reusing the actionable 'Set ... in ~/.clanker.yaml' phrasing of other provider errors.

Acceptance criteria

clanker ask with a fresh empty config prints a message naming clanker config init; choosing OpenAI explicitly but omitting the key still prints the OpenAI-specific message.

Severity: low · from holistic hardening review.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions