Skip to content

Conversation

graphcareful
Copy link
Contributor

@graphcareful graphcareful commented Oct 1, 2025

Summary

Add an option to prevent interpolation of env vars within config loading process. Useful for when the config value may contain reserved symbols such as "$" which would make Vector go and replace those values with values from the global environment. Behavior is to default to "on" which would not be a breaking change for existing users.

How did you test this PR?

Use this option

--disable-env-var-interpolation
  Disable interpolation of environment variables in configuration files

  [env: VECTOR_DISABLE_ENV_VAR_INTERPOLATION=]

Config:

sources:
  in:
    type: demo_logs
    format: json
transforms:
  tr:
    type: sample
    inputs:
      - in
    rate: "$RATE"
sinks:
  out:
    type: blackhole
    inputs:
      - tr

And in global environment, set RATE=12

Change Type

  • Bug fix
  • New feature
  • Non-functional (chore, refactoring, docs)
  • Performance

Is this a breaking change?

  • Yes
  • No

Does this PR include user facing changes?

  • Yes. Please add a changelog fragment based on our guidelines.
  • No. A maintainer will apply the no-changelog label to this PR.

References

Notes

  • Please read our Vector contributor resources.
  • Do not hesitate to use @vectordotdev/vector to reach out to us regarding this PR.
  • Some CI checks run only after we manually approve them.
    • We recommend adding a pre-push hook, please see this template.
    • Alternatively, we recommend running the following locally before pushing to the remote branch:
      • make fmt
      • make check-clippy (if there are failures it's possible some of them can be fixed with make clippy-fix)
      • make test
  • After a review is requested, please avoid force pushes to help us review incrementally.
    • Feel free to push as many commits as you want. They will be squashed into one before merging.
    • For example, you can run git merge origin master and git push.
  • If this PR introduces changes Vector dependencies (modifies Cargo.lock), please
    run make build-licenses to regenerate the license inventory and commit the changes (if any). More details here.

@graphcareful graphcareful requested a review from a team as a code owner October 1, 2025 19:31
/// Prepares input for a `ConfigBuilder` by interpolating environment variables.
fn prepare<R: Read>(&mut self, input: R) -> Result<String, Vec<String>> {
let prepared_input = prepare_input(input)?;
fn prepare<R: Read>(&mut self, mut input: R) -> Result<String, Vec<String>> {
Copy link
Member

Choose a reason for hiding this comment

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

I wonder if we want to do this check inside prepare_input which is implemented in src/config/loading/mod.rs. IIRC all prepare implementations delegate to that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll take a look at that

- Adds a new command line flag (also can be configured with the env var
VECTOR_DISABLE_ENV_VAR_INTERPOLATION) that when enabled will modify the
config loading process to skip over routines that interpolate
configuration values with values from the global environment.
@graphcareful graphcareful force-pushed the rob/global-interpolate-switch branch from 31eb923 to e48554e Compare October 1, 2025 19:51
@thomasqueirozb thomasqueirozb added the meta: awaiting author Pull requests that are awaiting their author. label Oct 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

meta: awaiting author Pull requests that are awaiting their author.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants