Skip to content

Conversation

bruceg
Copy link
Member

@bruceg bruceg commented Aug 12, 2025

Summary

serde allows the last variant in an internally tagged enum to be marked as untagged. This allows it to handle a schema that does not use the tag attribute for one of the variants. This change adds support to the configurable macro to accomodate this capability.

Vector configuration

N/A

How did you test this PR?

A new smoke test is included which passes.

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.

@bruceg bruceg requested a review from a team as a code owner August 12, 2025 00:18
@bruceg bruceg added type: tech debt A code change that does not add user value. domain: config Anything related to configuring Vector domain: schemas Anything related to internal Vector event schemas no-changelog Changes in this PR do not need user-facing explanations in the release changelog labels Aug 12, 2025
@bruceg bruceg requested a review from Copilot August 12, 2025 00:18
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds support for handling serde(untagged) in enum variants within the configurable macro. It allows the last variant in an internally tagged enum to be marked as untagged, which enables handling schemas that don't use the tag attribute for specific variants.

Key changes:

  • Added detection and validation of untagged variants in tagged enums
  • Implemented proper schema generation for untagged variants
  • Added comprehensive test coverage for the new functionality

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
lib/vector-config/tests/integration/smoke.rs Adds integration test for tagged enum with trailing untagged variant schema generation
lib/vector-config-macros/src/ast/variant.rs Modifies variant parsing to detect and handle serde(untagged) attributes
lib/vector-config-macros/src/ast/util.rs Adds utility function to check for flag-style attributes and refactors existing attribute parsing
lib/vector-config-macros/src/ast/container.rs Adds validation logic to ensure untagged variants are positioned correctly and used appropriately

serde allows the last variant in a tagged enum to be marked as `untagged`. This
allows it to handle a schema that does _not_ use the tag attribute for one of
the variants. This change adds support to the `configurable` macro to accomodate
this capability.
@bruceg bruceg force-pushed the bruceg/handle-untagged-enum-variant branch from 3bb0560 to 9e53d0f Compare August 12, 2025 00:27
@bruceg bruceg requested a review from pront August 13, 2025 16:24
Copy link
Contributor

@tessneau tessneau left a comment

Choose a reason for hiding this comment

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

lg from my end

@pront pront enabled auto-merge August 18, 2025 16:16
@pront pront added this pull request to the merge queue Aug 18, 2025
Merged via the queue into master with commit d035b63 Aug 18, 2025
86 checks passed
@pront pront deleted the bruceg/handle-untagged-enum-variant branch August 18, 2025 17:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
domain: config Anything related to configuring Vector domain: schemas Anything related to internal Vector event schemas no-changelog Changes in this PR do not need user-facing explanations in the release changelog type: tech debt A code change that does not add user value.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants