Skip to content

fix(stdlib): avoid panic in nom convert_error on lines >= 65535 bytes - #1847

Merged
pront merged 4 commits into
mainfrom
fix/nom-long-line-panic
Jul 7, 2026
Merged

fix(stdlib): avoid panic in nom convert_error on lines >= 65535 bytes#1847
pront merged 4 commits into
mainfrom
fix/nom-long-line-panic

Conversation

@pront

@pront pront commented Jul 2, 2026

Copy link
Copy Markdown
Member

Summary

The fix adds parsing::safe_convert_error(): if any line of the input is ≥ 65,535 bytes it returns a plain "line too long" message; otherwise it delegates to nom_language::error::convert_error as before. All four call sites are updated.

The helper is intentionally a workaround pending rust-bakery/nom#1868 (open since Oct 2025, maintainer has limited availability). A comment marks it for removal once that PR lands.

Change Type

  • Bug fix
  • New feature
  • Non-functional (chore, refactoring, docs)
  • Performance

Is this a breaking change?

  • Yes
  • No

How did you test this PR?

Added a unit test in parse_key_value that constructs a 65,535-byte line with no = delimiter and standalone_key=false, which forces a nom Err::Error at EOF. Without the fix this panics; with it the function returns Err.

Ran cargo fmt, ./scripts/clippy.sh, and the full parse_key_value unit test suite.

Does this PR include user facing changes?

  • Yes. Please add a changelog fragment based on
    our guidelines.

Changelog fragment: changelog.d/1848.fix.md

References

@pront
pront marked this pull request as ready for review July 7, 2026 18:36
@pront
pront requested a review from a team as a code owner July 7, 2026 18:36
Comment thread changelog.d/1848.fix.md Outdated
Comment thread src/parsing/mod.rs
Rust 1.87 capped the fmt width at 0xffff; nom's convert_error panics
when a parse error column >= 65536. This affects parse_key_value,
parse_cef, decode_mime_q, and parse_ruby_hash.

Add safe_convert_error() in the parsing module: delegates to
nom_language::error::convert_error for normal inputs; for inputs with
a line >= 65535 bytes it returns a plain message with the line and
column number instead. Deny direct calls to convert_error via clippy
to prevent regressions.

Workaround for rust-bakery/nom#1867. Fixes vectordotdev/vector#23606.
@pront
pront force-pushed the fix/nom-long-line-panic branch from b1c7b67 to 944fa06 Compare July 7, 2026 18:58
thomasqueirozb
thomasqueirozb previously approved these changes Jul 7, 2026
Comment thread clippy.toml Outdated
Comment thread changelog.d/1848.fix.md Outdated
@pront
pront enabled auto-merge July 7, 2026 19:29
@pront
pront added this pull request to the merge queue Jul 7, 2026
Merged via the queue into main with commit d8ed826 Jul 7, 2026
23 checks passed
@pront
pront deleted the fix/nom-long-line-panic branch July 7, 2026 19:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

thread 'vector-worker' panicked: Formatting argument out of range

2 participants