Skip to content

fix(providers): read opencode config file during credential discovery#1290

Merged
drew merged 1 commit into
NVIDIA:mainfrom
ericcurtin:fix-opencode-config-discovery/ec
May 12, 2026
Merged

fix(providers): read opencode config file during credential discovery#1290
drew merged 1 commit into
NVIDIA:mainfrom
ericcurtin:fix-opencode-config-discovery/ec

Conversation

@ericcurtin
Copy link
Copy Markdown
Contributor

@ericcurtin ericcurtin commented May 9, 2026

Summary

Supplement env-var discovery with API keys stored in the opencode
config file at $XDG_CONFIG_HOME/opencode/opencode.json. Keys under
provider.<name>.options.apiKey are surfaced as <NAME>_API_KEY env
vars; existing env vars take priority over file-sourced values.

Related Issue

N/A (reported via direct session)

Changes

  • OpencodeProvider::discover_existing now reads $XDG_CONFIG_HOME/opencode/opencode.json (defaulting to ~/.config/opencode/opencode.json) in addition to env vars
  • Extracts per-provider API keys from provider.<name>.options.apiKey and surfaces them as <NAME_UPPERCASE>_API_KEY credentials so they are injected into the sandbox environment
  • Env vars continue to take priority over the config file
  • Adds five unit tests: extraction of multiple providers, keyless providers (e.g. Ollama), empty keys, malformed JSON, missing provider section

Testing

  • mise run pre-commit passes
  • Unit tests added/updated (cargo test -p openshell-providers — 29 passed)
  • E2E tests added/updated (not applicable — provider discovery is local-only)

Checklist

  • Follows Conventional Commits
  • Commits are signed off (DCO)

@copy-pr-bot
Copy link
Copy Markdown

copy-pr-bot Bot commented May 9, 2026

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@ericcurtin
Copy link
Copy Markdown
Contributor Author

I have read the DCO document and I hereby sign the DCO.

@ericcurtin
Copy link
Copy Markdown
Contributor Author

recheck

@ericcurtin
Copy link
Copy Markdown
Contributor Author

@drew @johntmyers PTAL

drew
drew previously approved these changes May 12, 2026
@drew
Copy link
Copy Markdown
Collaborator

drew commented May 12, 2026

/ok to test

@copy-pr-bot
Copy link
Copy Markdown

copy-pr-bot Bot commented May 12, 2026

/ok to test

@drew, there was an error processing your request: E1

See the following link for more information: https://docs.gha-runners.nvidia.com/cpr/e/1/

@drew
Copy link
Copy Markdown
Collaborator

drew commented May 12, 2026

/ok to test 91e89e9

@drew
Copy link
Copy Markdown
Collaborator

drew commented May 12, 2026

@ericcurtin looks like lint checks are failing. If you pull the latest changes from main the lockfile failure should resolve itself.

@ericcurtin ericcurtin force-pushed the fix-opencode-config-discovery/ec branch from 91e89e9 to fb0d050 Compare May 12, 2026 10:15
@ericcurtin
Copy link
Copy Markdown
Contributor Author

@drew rebased and repushed, hopefully it passes this time

@ericcurtin ericcurtin force-pushed the fix-opencode-config-discovery/ec branch from f33ceef to 494f606 Compare May 12, 2026 13:26
Supplement env-var discovery with API keys stored in the opencode
config file at $XDG_CONFIG_HOME/opencode/opencode.json. Keys under
provider.<name>.options.apiKey are surfaced as <NAME>_API_KEY env
vars; existing env vars take priority over file-sourced values.
@ericcurtin ericcurtin force-pushed the fix-opencode-config-discovery/ec branch from 494f606 to aa6dcca Compare May 12, 2026 13:27
@drew
Copy link
Copy Markdown
Collaborator

drew commented May 12, 2026

/ok to test aa6dcca

@drew drew merged commit df5a8b9 into NVIDIA:main May 12, 2026
28 checks passed
@ericcurtin ericcurtin deleted the fix-opencode-config-discovery/ec branch May 12, 2026 16:54
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.

2 participants