Skip to content

feat(config): add env var substitution in config values - #1044

Merged
steipete merged 1 commit into
openclaw:mainfrom
sebslight:env-var-substitution
Jan 17, 2026
Merged

steipete merged 1 commit into
openclaw:mainfrom
sebslight:env-var-substitution

Conversation

@sebslight

Copy link
Copy Markdown
Contributor

Summary

Support ${VAR_NAME} syntax in any config string value, substituted at config load time.

{
  models: {
    providers: {
      "vercel-gateway": {
        apiKey: "${VERCEL_GATEWAY_API_KEY}"
      }
    }
  }
}
  • Only uppercase env vars matched: [A-Z_][A-Z0-9_]*
  • Missing/empty env vars throw MissingEnvVarError with path context
  • Escape with $${VAR} to output literal ${VAR}
  • Works with $include (included files also get substitution)
  • Substitution happens after $include resolution, before schema validation

Closes #1009

Test plan

  • 28 unit tests covering basic substitution, nested objects/arrays, missing var errors, escape syntax, and passthrough behavior
  • Full test suite passes (652 files, 3438 tests)
  • Lint and build pass

Support ${VAR_NAME} syntax in any config string value, substituted at
config load time. Useful for referencing API keys and secrets from
environment variables without hardcoding them in the config file.

- Only uppercase env vars matched: [A-Z_][A-Z0-9_]*
- Missing/empty env vars throw MissingEnvVarError with path context
- Escape with $${VAR} to output literal ${VAR}
- Works with $include (included files also get substitution)

Closes openclaw#1009
@steipete

Copy link
Copy Markdown
Contributor

Landed via temp rebase onto main.\n\n- Gate: pnpm lint && pnpm build && pnpm test\n- Land commit: 25399d3\n- Merge commit: 7310803\n\nThanks @sebslight!

dustin-olenslager pushed a commit to dustin-olenslager/ironclaw-supreme that referenced this pull request Mar 24, 2026
lovewanwan pushed a commit to lovewanwan/openclaw that referenced this pull request Apr 28, 2026
feat(config): add env var substitution in config values
lovewanwan pushed a commit to lovewanwan/openclaw that referenced this pull request Apr 28, 2026
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 9, 2026
feat(config): add env var substitution in config values
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 9, 2026
jameslcowan pushed a commit to jameslcowan/openclaw that referenced this pull request Jun 2, 2026
zeekay pushed a commit to Dream-AI-4444/clawdbot that referenced this pull request Sep 11, 2026
feat(config): add env var substitution in config values
zeekay pushed a commit to Dream-AI-4444/bot that referenced this pull request Sep 11, 2026
zooqueen pushed a commit to zooqueen/openclaw that referenced this pull request Sep 11, 2026
lhfer pushed a commit to lhfer/openclaw that referenced this pull request Oct 11, 2026
feat(config): add env var substitution in config values
lhfer pushed a commit to lhfer/openclaw that referenced this pull request Oct 11, 2026
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.

[Feature]: Support referencing environment variables in .clawdbot.json

2 participants