Skip to content

Conversation

Kalopsian-tz
Copy link
Contributor

@Kalopsian-tz Kalopsian-tz commented Aug 22, 2025

Summary

I was working on the unit test included in the config documented below which is invalid because filter_msg is listed in both no_outputs_from and outputs.extract_from.

The issue arises when you try to run the invalid test, instead of handling the issue cleanly, Vector panics instead:

$ vector test vector.yaml
thread 'main' panicked at src/config/unit_test/mod.rs:75:49:
An unexpected error occurred while executing unit tests. Please try again.: RecvError(())

This seems to happen because Vector doesn't include a check that output.extract_from entries are not also listed in no_outputs_from which allows it to pass the build phase and fail when the invalid test is unwrapped, causing the panic.

This PR adds a check which resolves the issue and lets Vector exit cleanly with a defined error that follows the format used by another error in the same function.

$ vector test vector.yaml
Running tests
2025-08-22T01:59:08.590667Z ERROR vector::unit_test: Failed to execute tests:
Failed to build test 'Invalid test':
  Invalid extract_from target in test 'Invalid test': 'filter_msg' listed in no_outputs_from.

PS: This is my first time raising a PR on an open source project so any feedback on how I raised / worded this PR would be greatly appreciated! (I hope its ok I made a PR without making an issue first? The contributing page said "For large PRs or for breaking changes, ensure your change has an issue!" I couldn't find another issue raised about this and figured this wasn't a large or breaking change)

Vector configuration

sources:
  cmd:
    type: exec
    command:
      - echo
      - "a message!"
    mode: scheduled
    scheduled:
      exec_interval_secs: 120

transforms:
  filter_msg:
    type: filter
    inputs:
      - cmd
    condition: |
      .message != "a message!"

tests:
- name: Invalid test
  no_outputs_from:
    - filter_msg
  inputs:
  - insert_at: filter_msg
    type: log
    log_fields:
      message: "a message!"
  outputs:
  - extract_from: filter_msg
    conditions:
    - type: vrl
      source: |
        assert_eq!(.message, "a message!")

sinks:
  console:
    type: console
    encoding:
      codec: json
    inputs:
      - filter_msg

How did you test this PR?

I trialed similar edge cases I could think of to ensure they also pass with this new check as well as running the suggested tests:

cargo fmt --all
cargo clippy --workspace --all-targets -- -D warnings

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:
      • cargo fmt --all
      • cargo clippy --workspace --all-targets -- -D warnings
      • cargo nextest run --workspace (alternatively, you can run cargo test --all)
  • 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 cargo vdev build licenses to regenerate the license inventory and commit the changes (if any). More details here.

@Kalopsian-tz Kalopsian-tz changed the title fix(resolve_outputs): Panic caused by edge case during unit test build fix(unit tests): Panic caused by edge case during unit test build Aug 22, 2025
@Kalopsian-tz Kalopsian-tz marked this pull request as ready for review August 22, 2025 06:29
@Kalopsian-tz Kalopsian-tz requested a review from a team as a code owner August 22, 2025 06:29
@pront pront added meta: awaiting author Pull requests that are awaiting their author. domain: unit tests Anything related to Vector's unit testing feature labels Sep 2, 2025
@github-actions github-actions bot removed the meta: awaiting author Pull requests that are awaiting their author. label Sep 5, 2025
@pront pront enabled auto-merge September 5, 2025 12:59
@pront pront added this pull request to the merge queue Sep 5, 2025
Merged via the queue into vectordotdev:master with commit 9c0cba6 Sep 5, 2025
54 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
domain: unit tests Anything related to Vector's unit testing feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants