Skip to content

fix(ai): an unset API key fails as a generic network error instead of naming the missing key #465

Closed

Description

@dan-petty

Problem

When no API key is configured (no DEVOPS_CLI_AI_API_KEY, no keyring entry), the OpenAI-compatible client still sends Authorization: Bearer with nothing after it. httpx refuses to send that header (LocalProtocolError: Illegal header value b'Bearer '), so the request never leaves the machine. The user sees only:

Error: Provider request failed. Check network access, API endpoint, and credentials.

This sends the user off to debug the network or the endpoint. Nothing reaches the server, so its logs show nothing either. Observed with devops ai chat on provider: gateway from a shell where the key had not been exported.

Expected

  • With no key, omit the Authorization header instead of sending an empty bearer token. A gateway or OpenAI-compatible server that needs no key then works, and one that does need a key answers with 401.
  • A 401 or 403 from the provider names the problem: the provider, and where the key is read from (DEVOPS_CLI_AI_API_KEY or the keyring).

Acceptance criteria

  • No request carries an empty Authorization header.
  • Missing or rejected credentials produce an error that names the key's sources, not a generic network error.
  • Tests cover an unset key and an authentication rejection.

Activity

  1. added this to the v0.2.23 milestone on Sep 23, 2026
  2. added
    type/bug
    scope/ai
    priority/p2-medium
    on Sep 23, 2026
  3. added a commit that references this issue on Sep 23, 2026
    8bce67d
  4. dan-petty commented on Sep 23, 2026

    @dan-petty
    OwnerAuthor

    Closed by #466, merged into release/v0.2.23.

    GitHub only acts on closing keywords when a pull request merges into the default branch, so this was closed by devops gh issues close-merged.

  5. added a commit that references this issue on Sep 28, 2026
    ea49d6e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority/p2-mediumscope/aitype/bug

    Type

    No type

    Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions