feat(config)!: parse config first, then interpolate into string leaves#25905
Draft
pront wants to merge 1 commit into
Draft
feat(config)!: parse config first, then interpolate into string leaves#25905pront wants to merge 1 commit into
pront wants to merge 1 commit into
Conversation
Inverts the order of config loading and interpolation: Vector now parses
YAML/TOML/JSON into a typed value tree first, then substitutes
environment variables and secrets only into string-typed leaves.
This closes the structural injection bug where env var values containing
YAML/TOML special characters (quotes, `>`, escape sequences) could corrupt
the parse. Previously a value like `password: ${PASS}` with PASS=fo">bar
would silently produce malformed config; now the substitution operates on
an already-valid tree and the value is treated as a plain string.
Breaking change: `${VAR}` and `SECRET[...]` placeholders must appear
inside quoted strings. Unquoted usages in TOML/JSON now emit a hint
pointing to the required quoting. YAML configs are generally unaffected
because YAML string detection is implicit.
Authors: pront
pront
force-pushed
the
pront/interpolation-after-parsing-v2
branch
from
July 20, 2026 18:56
c039afc to
b5706ef
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements RFC #25603: Vector now parses configuration files into a typed value tree before performing environment variable (
${VAR}) andSECRET[...]substitution.Key changes:
count = "${MY_COUNT}"withMY_COUNT=42works correctlysrc/config/vars.rsdeleted)set_env_var_interpolation()/env_var_interpolation_enabled()global OnceLock controls interpolation (same pattern as master's--dangerously-allow-env-var-interpolationflag)validate, andvector configcommands all use the same global flag consistentlyVector configuration
Before (TOML, now rejected):
After (TOML, quoted form works and coerces to int):
YAML is unaffected:
count: ${MY_COUNT}continues to work (YAML parses${VAR}as a string scalar and the coercion pass converts it to the declared type).How did you test this PR?
src/config/loading/interpolation.rsandschema_coercion.rscargo run -- validateagainst YAML/TOML/JSON configs with env var and secret placeholdersChange Type
Is this a breaking change?
Does this PR include user facing changes?
no-changeloglabel to this PR.References
--dangerously-allow-env-var-interpolation#25699 (--dangerously-allow-env-var-interpolationflag)