Skip to content

config: support environment variable macros in apiKeys#467

Merged
mostlygeek merged 1 commit intomainfrom
config-apikeys-env-macros
Jan 17, 2026
Merged

config: support environment variable macros in apiKeys#467
mostlygeek merged 1 commit intomainfrom
config-apikeys-env-macros

Conversation

@mostlygeek
Copy link
Owner

@mostlygeek mostlygeek commented Jan 17, 2026

Summary

  • Add ${env.VAR_NAME} macro support for apiKeys configuration field
  • Apply env macro substitution before validation checks
  • Add tests for env macro substitution in apiKeys

Summary by CodeRabbit

  • New Features

    • API keys now support environment variable substitution within configuration files.
    • Added validation to ensure API keys do not contain spaces following environment variable substitution.
  • Tests

    • Added comprehensive test suite covering environment variable substitution in API keys, including error handling validation for missing variables and empty keys after substitution.

✏️ Tip: You can customize this high-level summary in your review settings.

Add substituteEnvMacros support for apiKeys configuration field,
allowing API keys to be loaded from environment variables using
the ${env.VAR_NAME} syntax.

- Apply env macro substitution before validation
- Add tests for env macro substitution in apiKeys
@coderabbitai
Copy link

coderabbitai bot commented Jan 17, 2026

Walkthrough

The PR extends config loading to substitute environment variable macros in API keys during validation. The implementation adds macro expansion logic to each API key prior to validation, checks for spaces in substituted keys, and includes comprehensive test coverage for successful and failed substitutions.

Changes

Cohort / File(s) Summary
API Key Environment Variable Substitution
proxy/config/config.go, proxy/config/config_test.go
Modified LoadConfigFromReader to substitute environment variable macros in API keys before validation; added loop with index-based key updates, space validation, and error handling. Added comprehensive test suite TestConfig_APIKeys_EnvMacros with four subtests covering successful single/multiple substitutions, missing variable error propagation, and empty key validation.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related issues

Possibly related PRs

Suggested labels

enhancement, configuration

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding environment variable macro support for apiKeys configuration.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@mostlygeek
Copy link
Owner Author

mostlygeek commented Jan 17, 2026

Well the one reason to do #466 was not done 🤣 . At least I tested it.

@mostlygeek mostlygeek merged commit 8f2137c into main Jan 17, 2026
3 checks passed
@mostlygeek mostlygeek deleted the config-apikeys-env-macros branch January 17, 2026 07:11
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