vectordotdev / vectordotdev/vector
vdev example-config generator emits invalid configs for mutually-exclusive-but-optional fields
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 22.6k
- Forks
- 2.3k
- Avg merge
- 1d 7h
- Merged PRs (30d)
- 146
Description
Summary
The example-config generator emits a value for every field that has docs::examples metadata. It has no notion of "at most one of these fields", so for fields that are mutually exclusive but not required, it generates an example config that violates the component's own validation. The only existing mechanism, required_one_of, means "exactly one must be set" (it emits a JSON-Schema oneOf constraint and a docs note "Exactly one of X or Y must be set"). That is semantically wrong for fields where neither being set is valid.
Impact
check-generated-docs(which validates every generated example withvector validate --no-environment) fails on any sink whose mutually-exclusive fields both have examples.- Surfaced concretely by the
axiomsink in #26171:urlandregionare mutually exclusive but neither is required. The auto-generatedadvanced.yamlset both, failing validation.- Workaround:
url'sdocs::exampleswere removed so the generator only emitsregion. This keeps the example valid but degrades the docs: theurlfield no longer shows example values.
- Workaround:
Proposed fix
-
Deprecate the top-level flattened fields in favor of a non-flattened enum. The
axiomsink'surl/regionare currently flattened intoAxiomConfigas top-level fields. Deprecate them and introduce a single non-flattenedendpointfield that is an enum (e.g.endpoint: { type: url, url: ... }|endpoint: { type: region, region: ... }). Mutual exclusivity becomes structural — an enum can only be one variant — so the example generator produces valid configs naturally, and the "at most one" problem disappears for this sink. -
If the above is not possible/feasible/doesn't make sense for all sinks: Add "at most one" support to the example generator (docs-only metadata, e.g.
docs::exclusive/mutually_exclusive, distinct fromrequired_one_of's "exactly one" semantics) so generated examples stay valid during the deprecation period and for any future mutually-exclusive-but-optional fields. The generator emits only one member of the group (reusing the existing group-selection logic inmake_example_params), with no JSON-SchemaoneOfconstraint and no "exactly one required" docs note. -
After the deprecation window, remove the old top-level fields and the generator workaround, restoring full example values on the enum variants.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the example-config generator and its make_example_params group-selection logic; reproduce the failure through check-generated-docs or vector validate --no-environment using the axiom advanced.yaml case. Compare required_one_of with the desired optional-exclusivity semantics and assess the proposed endpoint/deprecation path. Done means generated examples validate while retaining endpoint examples.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- documentation, testing, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100