[PR #10952] fix: prioritize explicit provider config over stored auth #13615

Open
opened 2026-02-16 18:18:27 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/10952

State: open
Merged: No


Problem

Stored OAuth credentials in ~/.local/share/opencode/auth.json silently override explicit provider configuration in opencode.json, making it impossible to use custom provider endpoints (e.g., Azure Foundry) once credentials are stored.

Fixes #10950

Solution

This PR ensures that explicit provider configuration in opencode.json always takes precedence over stored credentials from auth.json.

Changes

  • Check if provider has explicit baseURL or apiKey before loading stored auth
  • Skip stored auth (API keys and OAuth) when explicit config exists
  • Add log messages for transparency when skipping stored auth
  • Apply fix to both regular auth and plugin auth loading (including GitHub Copilot Enterprise)

Behavior

Scenario Before After
Explicit config + stored auth Uses stored auth Uses explicit config
No explicit config + stored auth Uses stored auth Uses stored auth
Explicit config only Uses explicit config Uses explicit config

Example Log Output

When skipping stored auth, users will see:

INFO skipping stored auth for provider with explicit config {providerID: "anthropic", hasExplicitBaseURL: true, hasExplicitApiKey: true}

Testing

Tested with Azure Foundry configuration:

  • Explicit Azure config correctly overrides stored Anthropic OAuth
  • Stored auth still used when no explicit config present
  • Log messages provide transparency

Impact

This allows users to:

  • Use Azure Foundry endpoints for Anthropic models
  • Configure custom provider proxies
  • Override stored credentials without manual auth.json editing
**Original Pull Request:** https://github.com/anomalyco/opencode/pull/10952 **State:** open **Merged:** No --- ## Problem Stored OAuth credentials in `~/.local/share/opencode/auth.json` silently override explicit provider configuration in `opencode.json`, making it impossible to use custom provider endpoints (e.g., Azure Foundry) once credentials are stored. Fixes #10950 ## Solution This PR ensures that explicit provider configuration in `opencode.json` always takes precedence over stored credentials from `auth.json`. ### Changes - Check if provider has explicit `baseURL` or `apiKey` before loading stored auth - Skip stored auth (API keys and OAuth) when explicit config exists - Add log messages for transparency when skipping stored auth - Apply fix to both regular auth and plugin auth loading (including GitHub Copilot Enterprise) ### Behavior | Scenario | Before | After | |----------|--------|-------| | Explicit config + stored auth | Uses stored auth ❌ | Uses explicit config ✅ | | No explicit config + stored auth | Uses stored auth ✅ | Uses stored auth ✅ | | Explicit config only | Uses explicit config ✅ | Uses explicit config ✅ | ### Example Log Output When skipping stored auth, users will see: ``` INFO skipping stored auth for provider with explicit config {providerID: "anthropic", hasExplicitBaseURL: true, hasExplicitApiKey: true} ``` ## Testing Tested with Azure Foundry configuration: - Explicit Azure config correctly overrides stored Anthropic OAuth - Stored auth still used when no explicit config present - Log messages provide transparency ## Impact This allows users to: - Use Azure Foundry endpoints for Anthropic models - Configure custom provider proxies - Override stored credentials without manual `auth.json` editing
yindo added the pull-request label 2026-02-16 18:18:27 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#13615