← Back to Pull requests

fix(lua): truncate fractional numbers in timestamp fields #2066

Closed
unknown closed this pull request without merging on Nov 17, 2026 20:14 UTC
View on GitHub
unknown unknown commented on Nov 17, 2026 19:47 UTC
Author

Summary

Since the mlua 0.12 upgrade (#2040), a Lua timestamp with a fractional field fails to convert. mlua 0.11 truncated these values.

For example, this Vector Lua script worked before and now fails with number → u32: out of range, so the log is dropped:

event.log.timestamp = os.date("!*t", 1584297428)
event.log.timestamp.nanosec = 1e9 / 3
emit(event)

This PR restores the old behavior. table_to_timestamp now reads its fields through a private LuaInt<T> wrapper that truncates fractional numbers toward zero before converting, including numeric strings. Out-of-range and non-numeric values are still rejected.

This unblocks vectordotdev/vector#27241. No changelog, because the mlua 0.12 upgrade has not been released.

How did you test this PR?

Two new tests in src/value/value/lua.rs:

| Input | Expected |
| --- | --- |
| nanosec = 1e9 / 3 | 2020-03-15T18:37:08.333333333Z |
| sec = 8.9, nanosec = '333333333.9' | 2020-03-15T18:37:08.333333333Z |
| The script above (os.date('!*t', ...) and then nanosec = 1e9 / 3) | 2020-03-15T18:37:08.333333333Z |
| nanosec = -1.5 | Error |

  • With truncation temporarily disabled, the truncation test fails. The out-of-range test passes either way, so it only shows that rejecting bad values was not loosened.

  • cargo test --features lua --lib: all 1,988 tests pass.

  • cargo clippy --all-features --all-targets: no new warnings.
  • Vector compatibility (advisory) is expected to fail until vectordotdev/vector#27241 merges, because Vector master still uses mlua 0.11.

    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.
  • 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.

    References

  • Related: #2040

  • Related: https://github.com/vectordotdev/vector/pull/27241
  • Diff: 289 lines (+216 / -73) across 3 files Reviewer: pront Review duration: 26m
    All Vouch review confidence checks passed
    Residual risk 0.16 = Change Risk (0.40) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.40 · 289 lines diff across 3 files
    0.40
    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.339
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #2066"
    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: 39.8% (MEDIUM) · Higher = larger blast radius
    39.8%
    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: 15.7% · Safe to merge
    15.7%