-
Notifications
You must be signed in to change notification settings - Fork 1.8k
chore(config): Handle serde(untagged)
in enum variants
#23575
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this 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.
3bb0560
to
9e53d0f
Compare
There was a problem hiding this 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
Summary
serde
allows the last variant in an internally tagged enum to be marked asuntagged
. This allows it to handle a schema that does not use the tag attribute for one of the variants. This change adds support to theconfigurable
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
Is this a breaking change?
Does this PR include user facing changes?
no-changelog
label to this PR.References
Notes
@vectordotdev/vector
to reach out to us regarding this PR.pre-push
hook, please see this template.cargo fmt --all
cargo clippy --workspace --all-targets -- -D warnings
cargo nextest run --workspace
(alternatively, you can runcargo test --all
)git merge origin master
andgit push
.Cargo.lock
), pleaserun
cargo vdev build licenses
to regenerate the license inventory and commit the changes (if any). More details here.