Skip to content

Override most config values with env var - #2850

Open
dwwoelfel wants to merge 1 commit into
mainfrom
config-env-var-override
Open

Override most config values with env var#2850
dwwoelfel wants to merge 1 commit into
mainfrom
config-env-var-override

Conversation

@dwwoelfel

Copy link
Copy Markdown
Contributor

Allows most config values from the config edn file to be supplied by an env var.

:s3-storage-access-key -> INSTANT_CONFIG_S3_STORAGE_ACCESS_KEY
:s3-storage-secret-key -> INSTANT_CONFIG_S3_STORAGE_SECRET_KEY
:s3-endpoint -> INSTANT_CONFIG_S3_ENDPOINT
:s3-public-endpoint -> INSTANT_CONFIG_S3_PUBLIC_ENDPOINT
:s3-region -> INSTANT_CONFIG_S3_REGION
:s3-bucket-name -> INSTANT_CONFIG_S3_BUCKET_NAME
:database-url -> INSTANT_CONFIG_DATABASE_URL
:next-database-cluster-id -> INSTANT_CONFIG_NEXT_DATABASE_CLUSTER_ID
:postmark-token -> INSTANT_CONFIG_POSTMARK_TOKEN
:sendgrid-token -> INSTANT_CONFIG_SENDGRID_TOKEN
:postmark-account-token -> INSTANT_CONFIG_POSTMARK_ACCOUNT_TOKEN
:secret-discord-token -> INSTANT_CONFIG_SECRET_DISCORD_TOKEN
:stripe-secret -> INSTANT_CONFIG_STRIPE_SECRET
:stripe-webhook-secret -> INSTANT_CONFIG_STRIPE_WEBHOOK_SECRET
:honeycomb-api-key -> INSTANT_CONFIG_HONEYCOMB_API_KEY
:posthog-api-key -> INSTANT_CONFIG_POSTHOG_API_KEY
:rate-limit-hmac-key -> INSTANT_CONFIG_RATE_LIMIT_HMAC_KEY
:database-cluster-id -> INSTANT_CONFIG_DATABASE_CLUSTER_ID

We don't support

 :aead-keyset
 :cloudfront-signing-key
 :google-oauth-client
 :shared-oauth-clients
 :hybrid-keyset
 :webhook-keyset

@coderabbitai

coderabbitai Bot commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Configuration loading now derives environment variable names from declared string-valued keys, reads matching INSTANT_CONFIG_* values, obfuscates secret values, and merges the results into decrypted configuration.

Changes

Configuration environment overrides

Layer / File(s) Summary
Discover overridable configuration keys
server/src/instant/config_edn.clj
The configuration specs provide classified keys. config-env-var-name converts keys to INSTANT_CONFIG_* names. env-overrides reads matching environment variables and obfuscates secret values.
Merge overrides into decrypted configuration
server/src/instant/config_edn.clj, server/test/instant/config_edn_test.clj
Decrypted configuration merges environment overrides after EDN transformation. Tests cover naming, string-valued keys, structured keys, and empty environments.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Suggested reviewers: stopachka

Sequence Diagram(s)

sequenceDiagram
  participant ConfigLoader
  participant env-overrides
  participant Environment
  participant DecryptedConfig

  ConfigLoader->>DecryptedConfig: decrypt and transform EDN
  ConfigLoader->>env-overrides: request environment overrides
  env-overrides->>Environment: read INSTANT_CONFIG_* variables
  Environment-->>env-overrides: return matching values
  env-overrides-->>ConfigLoader: return obfuscated key-value map
  ConfigLoader->>DecryptedConfig: merge overrides
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: overriding configuration values with environment variables.
Description check ✅ Passed The description directly explains the environment variable overrides, supported configuration keys, and unsupported values.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
server/test/instant/config_edn_test.clj (1)

50-58: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Test populated environment overrides.

This test checks only an empty environment and overridable-key-type. It does not verify that env-overrides reads a value, keeps :s3-endpoint plain, and obfuscates :postmark-token.

Inject an environment lookup function, or use an equivalent fixture. Add assertions for both value types.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@server/test/instant/config_edn_test.clj` around lines 50 - 58, Extend
env-overrides-obfuscate-secrets-only to supply a populated environment lookup
fixture to config-edn/env-overrides, then assert that :s3-endpoint returns its
plain configured value while :postmark-token returns an obfuscated value. Keep
the existing empty-environment and overridable-key-type assertions, and use the
existing crypt-util/obfuscate behavior rather than bypassing it.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@server/src/instant/config_edn.clj`:
- Around line 216-234: Update decrypted-config so raw environment overrides are
merged into the source config-edn map before required-key validation and
s/conform; then apply the existing obfuscation/decryption postwalk and
env-overrides handling to the validated combined config without using
already-obfuscated values for validation. Add a regression test covering a
required production string key absent from EDN but supplied through
INSTANT_CONFIG_DATABASE_CLUSTER_ID.

---

Nitpick comments:
In `@server/test/instant/config_edn_test.clj`:
- Around line 50-58: Extend env-overrides-obfuscate-secrets-only to supply a
populated environment lookup fixture to config-edn/env-overrides, then assert
that :s3-endpoint returns its plain configured value while :postmark-token
returns an obfuscated value. Keep the existing empty-environment and
overridable-key-type assertions, and use the existing crypt-util/obfuscate
behavior rather than bypassing it.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: c10b81ef-8db0-4b94-8e72-a3fbeac1b5f4

📥 Commits

Reviewing files that changed from the base of the PR and between 30561b0 and 94756f1.

📒 Files selected for processing (2)
  • server/src/instant/config_edn.clj
  • server/test/instant/config_edn_test.clj

Comment thread server/src/instant/config_edn.clj
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