Skip to content

fix(config): load provider env vars#1445

Closed
Alix-007 wants to merge 3 commits intosipeed:mainfrom
Alix-007:pr/issue-836-provider-env-vars
Closed

fix(config): load provider env vars#1445
Alix-007 wants to merge 3 commits intosipeed:mainfrom
Alix-007:pr/issue-836-provider-env-vars

Conversation

@Alix-007
Copy link
Copy Markdown
Contributor

📝 Description

Make legacy providers.* environment variables load correctly by switching provider parsing to nested envPrefix tags that caarlos0/env actually resolves.

🗣️ Type of Change

  • 🐞 Bug fix (non-breaking change which fixes an issue)
  • ✨ New feature (non-breaking change which adds functionality)
  • 📖 Documentation update
  • ⚡ Code refactoring (no functional changes, no api changes)

🤖 AI Code Generation

  • 🤖 Fully AI-generated (100% AI, 0% Human)
  • 🛠️ Mostly AI-generated (AI draft, Human verified/modified)
  • 👨‍💻 Mostly Human-written (Human lead, AI assisted or none)

🔗 Related Issue

Fixes #836

📚 Technical Context (Skip for Docs)

  • Reference URL: [BUG] Unable to use environment vars for APIKEYS #836
  • Reasoning: the previous env:"PICOCLAW_PROVIDERS_{{.Name}}_*" tags are not expanded by the env loader, so provider API keys from environment variables were silently ignored. This patch replaces them with supported nested prefixes and adds regression coverage.

🧪 Test Environment

  • Hardware: PC
  • OS: Windows 11
  • Model/Provider: N/A
  • Channels: N/A

📸 Evidence (Optional)

Click to view Logs/Screenshots
  • go test ./pkg/config -run 'Test(LoadConfig_ProviderEnvVarsOverrideFileValues|LoadConfig_OpenAIProviderEnvVarsUseNestedPrefix|LoadConfig_WebToolsProxy|LoadConfig_OpenAIWebSearchDefaultsTrueWhenUnset|LoadConfig_OpenAIWebSearchCanBeDisabled)' -count=1

☑️ Checklist

  • My code/docs follow the style of this project.
  • I have performed a self-review of my own changes.
  • I have updated the documentation accordingly.

@sipeed-bot sipeed-bot bot added type: bug Something isn't working domain: config domain: provider go Pull requests that update go code labels Mar 12, 2026
@Alix-007
Copy link
Copy Markdown
Contributor Author

Follow-up update: I pushed a forward-only sync commit so provider values now pick up the nested PICOCLAW_PROVIDERS_* environment prefixes on the current config layout. Local validation on this branch: go test ./pkg/config -run TestLoadConfig_ProviderEnvVarsOverrideFileValues -count=1 and go test ./pkg/config -run TestLoadConfig_OpenAIProviderEnvVarsUseNestedPrefix -count=1 both pass.

@Alix-007
Copy link
Copy Markdown
Contributor Author

Follow-up update: I replaced the tag-based attempt with a forward-only post-parse env override so nested PICOCLAW_PROVIDERS_* values now load without touching the current struct-tag hotspot. Local validation: go test ./pkg/config -run TestLoadConfig_ProviderEnvVarsOverrideFileValues -count=1 and go test ./pkg/config -run TestLoadConfig_OpenAIProviderEnvVarsUseNestedPrefix -count=1 both pass, and a real local merge against current main now succeeds.

@Alix-007
Copy link
Copy Markdown
Contributor Author

I rebuilt this fix on top of the current main and re-ran go test ./pkg/config -count=1 locally. The code path is still valid, but I cannot update this PR branch with the refreshed history because GitHub is rejecting the push without workflow scope once the branch picks up the current .github/workflows/docker-build.yml changes from upstream.

@Alix-007 Alix-007 closed this Mar 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

domain: config domain: provider go Pull requests that update go code type: bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Unable to use environment vars for APIKEYS

1 participant