← Back to Pull requests

fix(value): preserve values when insertion paths are invalid #2080

Closed
unknown closed this pull request without merging on Nov 23, 2026 17:58 UTC
View on GitHub
unknown unknown commented on Nov 23, 2026 15:54 UTC
Author

<!--
We recommend conforming to conventional commit spec for PR titles:
https://www.conventionalcommits.org/en/v1.0.0/

<type>(<scope>)!: <description>

type = chore, enhancement, feat, fix, docs, revert
! = OPTIONAL: signals a breaking change
scope = Optional when type is "chore" or "docs"
description = short description of the change

Examples:

enhancement(file source): Add sort option to sort discovered files
feat(new source): Initial statsd source
fix(file source): Fix a bug discovering new files
chore(external docs): Clarify batch_size option
-->

Summary

Prevent Value::insert from modifying existing data when a path contains BorrowedSegment::Invalid.

Recursive insertion now distinguishes an invalid path from a successful insertion with no previous value. Replacement objects and arrays are installed only after recursive insertion succeeds. The public Option<Value> API is unchanged: invalid paths still return None. This avoids an additional path-validation pass or cloning the original value.

Update the invalid-path compatibility test introduced in #2044: five cases intentionally change from preserving partial mutations to preserving the original value. Add coverage for forward/backward array growth, nested array-element replacement, and invalid segments followed by more segments. The other compatibility tests remain unchanged.

This addresses the Rust API reproducer in #2070; a trigger through an ordinary VRL program or Vector configuration has not been established. Changing the public return type is outside this PR's scope.

<!-- Please provide a brief summary about what this PR does.
This should help the reviewers give feedback faster and with higher quality. -->

How did you test this PR?

Reproduced the original issue before the fix using a standalone crate with only the value feature enabled. The preservation assertion failed before the fix and passed afterward. The updated regression test was also observed failing before the implementation change.

After resolving the conflict with upstream's ObjectMap change, all 103 value-library tests, the doctest, focused Clippy, formatting, and changelog validation passed:

cargo test --locked --no-default-features --features value --lib
cargo test --locked --no-default-features --features value --doc
cargo clippy --locked --no-default-features --features value --lib --tests --bench value_insert -- -D warnings
cargo fmt --all --check
cargo run --locked -p release -- check-changelog

All 45 benchmark smoke cases passed before the upstream update; they were not rerun afterward. Full make all, all-feature validation, and comparative performance benchmarks were not run. Current focused checks emit unused-dependency manifest warnings for serde_yaml_ng and ua-parser.

<!-- Please describe your testing plan here.
Providing this information upfront will facilitate a smoother review process. -->

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.
  • Added changelog.d/invalid-insert-preserves-value.fix.md.

    Checklist

  • Our CONTRIBUTING.md is a good starting place.

  • If this PR introduces changes to LICENSE-3rdparty.csv, please

  • run dd-rust-license-tool write and commit the changes. More details here.

    No dependency or license-file changes.

    References

    Closes #2070.

    Related: #2044; https://github.com/vectordotdev/vector/issues/21213 (separate return-type/API discussion).

    <!-- Please list any issues closed by this PR. -->

    <!--

  • Closes: <issue link>

  • -->

    <!-- Any other issues or PRs relevant to this PR? Feel free to list them here. -->

    Diff: 505 lines (+378 / -127) across 6 files Reviewer: pront Review duration: 124m
    All Vouch review confidence checks passed
    Residual risk 0.19 = Change Risk (0.48) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.48 · 505 lines diff across 6 files
    0.48
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.373
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #2080"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 47.6% (MEDIUM) · Higher = larger blast radius
    47.6%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 18.8% · Safe to merge
    18.8%