Skip to content

fix(ai): gateway provider sends requests and its key to ai.api_base_url instead of ai.gateway_url #455

Closed

Description

@dan-petty

Problem

OpenAICompatProviderMixin._api_base (src/devops_cli/ai/client/openai.py) returns api_base_url before it considers gateway_url, for every provider:

if self._config.api_base_url:
    return self._validate_base_url(self._config.api_base_url, purpose="provider API")
if self._config.provider == "gateway":
    gw_url = getattr(self._config, "gateway_url", None) or DEFAULT_AI_GATEWAY_URL

ai.api_base_url is commonly set for the openai provider (e.g. https://api.openai.com/v1) and for_task merges it into every task. A task with provider: gateway therefore sends its requests, with Authorization: Bearer <ai api key>, to the OpenAI endpoint instead of the configured gateway. The gateway master key is disclosed to a third party; OpenAI answers 401 and the request fails.

Observed while pointing devops ai chat at a LiteLLM gateway: the request went to https://api.openai.com/v1/chat/completions and carried the gateway key, which then had to be rotated.

Expected

For provider: gateway, a task-level api_base_url may override, but a global api_base_url inherited from another provider's setup must not outrank gateway_url. At minimum, never send a request for provider gateway to a host other than the gateway's.

Workaround

Set ai.tasks.<task>.api_base_url to the gateway URL.

Acceptance criteria

  • Provider gateway resolves to gateway_url unless the task itself sets api_base_url.
  • Tests cover global vs task-level api_base_url with provider gateway.

Activity

  1. added this to the v0.2.23 milestone on Sep 23, 2026
  2. added
    type/security
    scope/ai
    priority/p1-high
    on Sep 23, 2026
  3. added 2 commits that reference this issue on Sep 23, 2026
    f6a5e0c
    8c576e0
  4. dan-petty commented on Sep 23, 2026

    @dan-petty
    OwnerAuthor

    Closed by #462, 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/p1-highscope/aitype/security

    Type

    No type

    Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions