Skip to content

Fix: Expand environment variables in AI API key configuration#21

Merged
epuerta9 merged 1 commit into
mainfrom
fix/provider-config-env-expansion
Aug 7, 2025
Merged

Fix: Expand environment variables in AI API key configuration#21
epuerta9 merged 1 commit into
mainfrom
fix/provider-config-env-expansion

Conversation

@epuerta9
Copy link
Copy Markdown
Collaborator

@epuerta9 epuerta9 commented Aug 7, 2025

Summary

  • Fix environment variable expansion in ai_api_key config loading
  • Resolves OpenAI 401 errors where ${OPENAI_API_KEY} wasn't being expanded
  • Prevents unintended fallback to Gemini provider

Changes

  • Added os.ExpandEnv() to config loading in /internal/config/config.go
  • Handles both direct API keys (sk-1234...) and env vars (${OPENAI_API_KEY})
  • Preserves unexpanded form for missing env vars to show better error messages
  • Maintains backward compatibility with existing configurations

Test plan

  • Verified agents now use OpenAI correctly (no more 401 errors)
  • Tested with both direct keys and ${ENV_VAR} syntax
  • Station service logs show correct provider initialization
  • Build completes successfully

Before/After

Before: ${OPENAI_API_KEY} sent literally → 401 Unauthorized
After: Environment variable expanded → Successful OpenAI calls

🤖 Generated with Claude Code

Fixes issue where ${OPENAI_API_KEY} in config.yaml wasn't being expanded,
causing agents to use literal string instead of actual API key value.

Changes:
- Added os.ExpandEnv() to ai_api_key config loading
- Handles both direct API keys and ${ENV_VAR} syntax
- Preserves unexpanded form for missing env vars to show better errors
- Maintains backward compatibility with existing configs

Resolves OpenAI 401 errors and prevents fallback to Gemini provider.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@epuerta9 epuerta9 merged commit c45f464 into main Aug 7, 2025
1 of 10 checks passed
epuerta9 added a commit that referenced this pull request Aug 11, 2025
…sion

Fix: Expand environment variables in AI API key configuration
epuerta9 added a commit that referenced this pull request Aug 30, 2025
…sion

Fix: Expand environment variables in AI API key configuration
epuerta9 added a commit that referenced this pull request Sep 2, 2025
…sion

Fix: Expand environment variables in AI API key configuration
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.

1 participant