Skip to content

refactor(config): prepare schema-driven value coercion - #26450

Open
pront wants to merge 7 commits into
masterfrom
pront-prepare-schema-coercion
Open

pront wants to merge 7 commits into
masterfrom
pront-prepare-schema-coercion

Conversation

@pront

@pront pront commented Sep 21, 2026

Copy link
Copy Markdown
Member

Summary

Extract the schema-coercion groundwork from #25905 so it can be reviewed independently of the breaking parse-first loading change.

  • Introduce ValueCoercer to keep the root schema, definition lookup, and error-path state together, with tests in a separate module.
  • Cover scalar coercion, references, arrays, unions, generated ConfigBuilder schemas, and numeric boundaries. Reject the rounded 2^63 float boundary instead of silently saturating it to i64::MAX.
  • Leave runtime loading unchanged: the loader does not invoke the new coercer. Serde remains the authoritative validator.

References

Related: #25905. Follows merged #26441; based directly on master, not stacked.

How did you test this PR?

  • make fmt and cargo fmt --all -- --check passed.
  • cargo nextest run -p vector --lib --no-default-features --features sources-demo_logs config::loading: 39 passed, including 12 coercion tests. A repeat run was clean after one passing test was marked leaky on the first run.
  • Production-library Clippy passed with sources-demo_logs and warnings denied.
  • make check-clippy FEATURES=sources-demo_logs is blocked by the existing clippy::unused_async finding at src/test_util/http.rs:51; that file is unchanged from master.

Does this PR include user facing changes?

  • Yes.
  • No. A maintainer will apply the no-changelog label to this PR.

@pront
pront requested a review from a team as a code owner September 21, 2026 19:20
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 21, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-22T20:38:14.539625Z 843df8e New commits
🔒 Security Review Completed 2026-09-22T20:35:23.236444Z 843df8e New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@pront pront added the no-changelog Changes in this PR do not need user-facing explanations in the release changelog label Sep 21, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 696b6b1b32

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/config/loading/schema_coercion.rs
Comment thread src/config/loading/schema_coercion.rs Outdated
Comment thread src/config/loading/schema_coercion.rs Outdated
Comment thread src/config/loading/schema_coercion.rs

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 10235e9b28

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/config/loading/schema_coercion.rs Outdated
Comment thread src/config/loading/schema_coercion.rs Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: fc43d7138d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/config/loading/schema_coercion.rs Outdated
Comment thread src/config/loading/schema_coercion.rs Outdated
Comment thread src/config/loading/schema_coercion.rs Outdated
@pront
pront force-pushed the pront-prepare-schema-coercion branch from fc43d71 to 599ec6d Compare September 22, 2026 19:04

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 034c98fd38

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/config/loading/schema_coercion.rs Outdated
Comment thread src/config/loading/schema_coercion.rs Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 843df8e5d2

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +880 to +884
if let Some(schema_type) = schema.get("type") {
return match schema_type {
Value::String(schema_type) => value_matches_type(value, schema_type),
Value::Array(schema_types) => schema_types
.iter()

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Infer const types before ranking union branches

When an optional externally tagged unit enum has a valid variant spelling "null", its generated Option schema places the null branch before the enum branch, but this function reports no structural match for the enum's const-only schema because it only recognizes explicit type values. Both branches therefore reach the coercive pass, where the null branch converts "null" to JSON null and commits, causing serde to produce None instead of the enum variant. The fresh evidence beyond the earlier Option<SensitiveString> fix is that generate_const_string_schema emits const without type, which this recursive shape check still cannot classify; infer scalar shape from const and enum before ranking branches.

Useful? React with 👍 / 👎.

This branch has not been deployed

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

Labels

no-changelog Changes in this PR do not need user-facing explanations in the release changelog

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant