Skip to content

Conversation

esensar
Copy link
Contributor

@esensar esensar commented Oct 16, 2025

Summary

Diff calculation considered source keys (which are different than component keys in the case of enrichment tables) to find differences in configuration. This caused crashes when that component couldn't be found, because it has a different key in the configuration. This fix changes that to use the original component key for such lookups.

Vector configuration

Any configuration with an enrichment table configured to also act as a source, but I have used an example from one omy previous tests (#23815):

enrichment_tables:
  memory_table:
    type: memory
    ttl: 10
    flush_interval: 5
    inputs: ["cache_generator"]
    source_config:
       source_key: "memory_table_source"
       export_expired_items: true

sources:
  demo_logs_test:
    type: "demo_logs"
    format: "json"

transforms:
  demo_logs_processor:
    type: "remap"
    inputs: ["demo_logs_test"]
    source: |
      . = parse_json!(.message)
      user_id = get!(., path: ["user-identifier"])

      # Look for existing value in the table, using "user-identifier" as key
      existing, err = get_enrichment_table_record("memory_table", { "key": user_id })

      if err == null {
        . = existing.value
        .source = "cache"
      } else {
        .referer = parse_url!(.referer)
        .referer.host = encode_punycode!(.referer.host)
        .source = "transform"
      }

  cache_generator:
    type: "remap"
    inputs: ["demo_logs_processor"]
    source: |
      existing, err = get_enrichment_table_record("memory_table", { "key": get!(., path: ["user-identifier"]) })
      if err != null {
        data = .
        . = set!(value: {}, path: [get!(data, path: ["user-identifier"])], data: data)
      } else {
        . = {}
      }

# We can observe that after some time data will be dumped to console from the cache
sinks:
  console:
    inputs: ["memory_table_source.expired"]
    target: "stdout"
    type: "console"
    encoding:
      codec: "json"

How did you test this PR?

Ran the above configuration and issued kill -HUP {pid} targeting the Vector process. Before this patch, crash occurred:

2025-10-16T13:39:49.363211Z  INFO vector::topology::running: Reloading running topology with new configuration.

thread 'main' panicked at src/config/diff.rs:140:58:
no entry found for key
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

After the patch, the crash no longer occurs and reload is successfully executed.

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.

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.

Sponsored by Quad9

…t table sources

Diff calculation considered source keys (which are different than component keys in the case of
enrichment tables) to find differences in configuration. This caused crashes when that component
couldn't be found, because it has a different key in the configuration. This fix changes that to use
the original component key for such lookups.
@esensar esensar requested a review from a team as a code owner October 16, 2025 14:01
@github-actions github-actions bot added the domain: topology Anything related to Vector's topology code label Oct 16, 2025
@pront
Copy link
Member

pront commented Oct 16, 2025

Is this something that we can unit test?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

domain: topology Anything related to Vector's topology code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants