Skip to content

fix(cli): validate VRL with --no-environment#25161

Open
pront wants to merge 9 commits into
masterfrom
codex/fix-validate-no-environment-vrl
Open

fix(cli): validate VRL with --no-environment#25161
pront wants to merge 9 commits into
masterfrom
codex/fix-validate-no-environment-vrl

Conversation

@pront

@pront pront commented Apr 10, 2026

Copy link
Copy Markdown
Member

Summary

vector validate --no-environment is meant for validating configs without access to environment resources (network, file system, external services). However, it silently skipped transform-level VRL and condition compilation, so errors like unhandled fallible function calls or type mismatches went unreported unless the full environment was available.

This PR fixes that by unifying the validation path: transform compilation now runs in both --no-environment and normal mode, with the normal mode additionally running the full environment checks on top. Stub enrichment tables are registered from the config so VRL can validate enrichment table name references without loading actual data.

As a cleanup, the validate() call was also removed from check_outputs — that function is for graph/wiring checks only and should not invoke environment-dependent logic.

Vector configuration

Broken VRL — caught with --no-environment:

# /tmp/test_broken_vrl.yaml
sources:
  in:
    type: demo_logs
    format: shuffle
    lines: ["log"]

transforms:
  broken:
    inputs: ["in"]
    type: remap
    source: ".foo = to_int(.bar)"  # to_int is fallible, missing !

sinks:
  out:
    inputs: ["broken"]
    type: blackhole

Broken condition — caught with --no-environment:

# /tmp/test_broken_filter.yaml
sources:
  in:
    type: demo_logs
    format: shuffle
    lines: ["log"]

transforms:
  broken:
    inputs: ["in"]
    type: filter
    condition: '.foo = "not a condition"'

sinks:
  out:
    inputs: ["broken"]
    type: blackhole

Valid config — passes:

# /tmp/test_valid.yaml
sources:
  in:
    type: demo_logs
    format: shuffle
    lines: ["log"]

transforms:
  enrich:
    inputs: ["in"]
    type: remap
    source: '.foo = "bar"'

sinks:
  out:
    inputs: ["enrich"]
    type: blackhole

How did you test this PR?

# Should FAIL — to_int is fallible, missing !
cargo run --bin vector -- validate --no-environment /tmp/test_broken_vrl.yaml

# Should FAIL — assignment in condition, not a boolean expression
cargo run --bin vector -- validate --no-environment /tmp/test_broken_filter.yaml

# Should pass
cargo run --bin vector -- validate --no-environment /tmp/test_valid.yaml

Also ran the CLI integration test suite:

cargo test --test integration --features cli-tests

Change Type

  • Bug fix

Is this a breaking change?

  • No

Does this PR include user facing changes?

  • Yes. Changelog fragment added: changelog.d/15037_validate_no_environment_vrl.fix.md

References

@github-actions github-actions Bot added the domain: transforms Anything related to Vector's transform components label Apr 10, 2026
@pront pront force-pushed the codex/fix-validate-no-environment-vrl branch 3 times, most recently from e9d4c36 to fd1b169 Compare June 18, 2026 12:48
@github-actions github-actions Bot added the domain: topology Anything related to Vector's topology code label Jun 18, 2026
@pront pront force-pushed the codex/fix-validate-no-environment-vrl branch 3 times, most recently from ed733f4 to 8b87dfe Compare June 18, 2026 14:36
@pront pront changed the title fix(cli): validate transform VRL with --no-environment fix(cli): validate VRL with --no-environment Jun 18, 2026
@pront pront force-pushed the codex/fix-validate-no-environment-vrl branch 2 times, most recently from 187f6f2 to 33903f0 Compare June 18, 2026 18:21
@github-actions github-actions Bot removed the domain: topology Anything related to Vector's topology code label Jun 18, 2026
@datadog-vectordotdev

datadog-vectordotdev Bot commented Jun 19, 2026

Copy link
Copy Markdown

Tests

🎉 All green!

🧪 All tests passed
❄️ No new flaky tests detected

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: de6c7e0 | Docs | Give us feedback!

@pront pront force-pushed the codex/fix-validate-no-environment-vrl branch 3 times, most recently from 607ad63 to 5465781 Compare June 22, 2026 19:55
@github-actions github-actions Bot added docs review on hold The documentation team reviews PRs only after a PR is approved by the COSE team. domain: external docs Anything related to Vector's external, public documentation and removed docs review on hold The documentation team reviews PRs only after a PR is approved by the COSE team. labels Jun 22, 2026
@pront pront force-pushed the codex/fix-validate-no-environment-vrl branch from 5465781 to 2504092 Compare June 22, 2026 20:03
@github-actions github-actions Bot added the docs review on hold The documentation team reviews PRs only after a PR is approved by the COSE team. label Jun 22, 2026
@pront pront force-pushed the codex/fix-validate-no-environment-vrl branch 2 times, most recently from fb35df8 to 54393be Compare June 22, 2026 20:07
@github-actions github-actions Bot removed the domain: external docs Anything related to Vector's external, public documentation label Jun 22, 2026
@pront pront marked this pull request as ready for review June 22, 2026 20:09
@pront pront requested a review from a team as a code owner June 22, 2026 20:09

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 54393bea2d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/validate.rs Outdated
Comment thread src/validate.rs
Comment thread src/validate.rs
@pront pront force-pushed the codex/fix-validate-no-environment-vrl branch from 54393be to 24d9506 Compare June 22, 2026 20:36
@pront pront force-pushed the codex/fix-validate-no-environment-vrl branch from 24d9506 to b3e7b2a Compare June 22, 2026 20:39

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b3e7b2ac8b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/config/validation.rs Outdated
Comment thread src/config/validation.rs Outdated
Comment thread tests/integration/cli.rs
vector validate --no-environment now catches VRL compilation errors and
invalid condition expressions in transforms before any environment
resources are available.

Design:
- Add validate(&TransformContext) to TransformConfig; remap and filter
  implement it to compile VRL programs and conditions respectively
- route, exclusive_route, and sample also validate their condition fields
- Introduce validate_transforms(), called in both --no-environment and
  normal validate paths, which builds stub enrichment tables from the
  config so VRL can resolve table name references without loading data
- Remove the validate() call from check_outputs: that function is for
  graph/wiring checks only; transform compilation belongs in
  validate_transforms()
- Short-circuit environment checks when transform validation fails to
  avoid running health checks against external services for known-invalid
  configs
- Add transforms-filter and transforms-aws_ec2_metadata to cli-tests
  feature set so the new integration tests compile correctly
- Convert all CLI integration test configs to YAML; add create_yaml_file
  helper so test files carry the .yaml extension Vector uses for format
  detection

Fixes #15037
@pront pront force-pushed the codex/fix-validate-no-environment-vrl branch from b3e7b2a to 6077a2f Compare June 22, 2026 21:51
pront added 2 commits June 22, 2026 19:32
… cli-test features

check_outputs checks output port names against reserved names using
get_transform_output_ids, which includes auto-generated ports like the
_unmatched output that route/exclusive_route emit by default. Checking
_unmatched there falsely rejects all valid route configs. The reserved
route name check belongs in route::validate (called via
validate_transforms), not in the shared graph validation path.

Also add transforms-filter and transforms-aws_ec2_metadata to the
cli-tests feature set so the new integration tests compile in CI.
…t transform validation

Clean separation between two distinct validation concerns:

- validate(): structural config checks (reserved names, duplicate routes,
  invalid sample rates). Always safe to call, runs via check_outputs on
  every config load path including normal startup and reload.

- validate_env(): environment-dependent checks (VRL compilation, condition
  building). Called only by validate_transforms() in vector validate with
  a real TransformContext that includes stub enrichment tables.

remap and filter implement validate_env() for VRL/condition compilation.
route, exclusive_route, and sample split their existing validate() into
structural checks (validate) and condition compilation (validate_env).
validate_transforms() calls both on each transform.

Also adds a negative integration test asserting that an invalid filter
condition is caught under --no-environment.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 973f13b5e5

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/config/transform.rs
pront added 6 commits June 23, 2026 11:20
…uce transforms

These transforms compile AnyCondition fields only in build(), so invalid
conditions were silently accepted under --no-environment. Now validate_env()
covers: delay.condition, window.forward_when/flush_when, throttle.exclude,
and reduce.ends_when/starts_when.
…to validate()

Constraints that don't require environment resources were previously only
checked inside build(), so they weren't caught by vector validate
--no-environment or normal config compilation:

- delay: zero delay duration
- throttle: zero threshold or window_secs
- reduce: mutually exclusive ends_when/starts_when
validate_merge_strategies() in transform.rs only ran during build(),
so --no-environment silently accepted indexed paths like foo[0].
Move the check into ReduceConfig::validate() so it runs on all
config load paths.
…s of transform errors

Gating validate_environment on the transform pass result meant a VRL
error would suppress environment/component errors, giving users an
incomplete error picture. Both passes now run independently and their
results are combined.
@github-actions github-actions Bot removed the docs review on hold The documentation team reviews PRs only after a PR is approved by the COSE team. label Jun 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

domain: transforms Anything related to Vector's transform components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Validate no-environment should perform transform/filter VRL checks

2 participants