Skip to content

Fix parser crash on chunk line-wrap from long filenames#290

Merged
nitrobass24 merged 1 commit intodevelopfrom
fix/parser-chunk-line-wrap
Mar 18, 2026
Merged

Fix parser crash on chunk line-wrap from long filenames#290
nitrobass24 merged 1 commit intodevelopfrom
fix/parser-chunk-line-wrap

Conversation

@nitrobass24
Copy link
Owner

@nitrobass24 nitrobass24 commented Mar 17, 2026

Summary

Fix lftp parser crash when long filenames cause chunk progress lines to wrap across PTY boundaries.

Problem

Files with very long names (e.g. 1923 (2022) S01E04 (1080p SKST WEB-DL DDP5.1 H264)-Vialle.mkv) produce chunk progress lines that exceed the PTY width. The line wraps, and the parser sees a tail fragment like:

tmos.7.1.DV.HDR.H.265-TheFarm.mkv' at 22283455338 (0%) 427.6K/s eta:28m [Receiving data]

This fragment is missing the leading backtick (`) and start of the filename, so the chunk_at pattern can't match it. The parser raises ValueError, which crashes the controller and restarts the app.

This is the same class of bug as #253 and #260 (Unraid PTY wrapping), but for a different fragment type.

Fix

Add a chunk_wrap_m pattern that matches these tail fragments: lines that end with ' at <pos> (<pct>%) [<speed>] [eta:<time>] [<status>] but don't start with a backtick or backslash. These are safely skipped alongside existing orphan/partial progress line handling.

Test plan

  • 3 new regression tests: fragment after job, bare fragment, fragment with [Connecting...] status
  • CI passes

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes

    • Improved parsing robustness to correctly ignore wrapped progress fragments in job status output, preventing false-positive parse results and crashes.
  • Tests

    • Added regression tests covering wrapped progress fragments and edge-wrap scenarios to ensure consistent, reliable status parsing across varied output formats.

@coderabbitai
Copy link

coderabbitai bot commented Mar 17, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 1325e4ab-bd08-4734-8ff7-c484e9bf08fb

📥 Commits

Reviewing files that changed from the base of the PR and between 5ef56e1 and 6a204d0.

📒 Files selected for processing (2)
  • src/python/lftp/job_status_parser.py
  • src/python/tests/unittests/test_lftp/test_job_status_parser.py

📝 Walkthrough

Walkthrough

A new regex pattern is added to recognize and skip wrapped progress lines in lftp output where long filenames cause line wrapping. The pattern is applied during header validation and end-of-line processing to treat wrapped chunk fragments as ignorable orphan progress lines, improving parsing robustness without affecting public APIs.

Changes

Cohort / File(s) Summary
Parser Logic
src/python/lftp/job_status_parser.py
Added chunk_wrap_m regex to detect wrapped chunk/progress line fragments and applied it in header/validation and end-of-line handling to skip those orphan fragments and avoid false-positive parse results.
Regression Tests
src/python/tests/unittests/test_lftp/test_job_status_parser.py
Added tests covering wrapped chunk progress fragments: test_chunk_line_wrap_fragment_skipped_after_job, test_bare_chunk_line_wrap_fragment_skipped, test_chunk_line_wrap_fragment_connecting, and test_chunk_line_wrap_at_quote_boundary.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

Suggested labels

bug

Poem

🐰 A wrapped line once broke my parse flow,
But a regex pattern stole the show—
Now chunks that wrap won't cause a fuss,
Just skip on by, no muss or cuss!
The rabbit hops through logs so bright,
Parsing peace throughout the night.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly and concisely describes the main fix: preventing parser crashes when chunk progress lines wrap due to long filenames, which is the core change across both modified files.
Docstring Coverage ✅ Passed Docstring coverage is 85.71% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/parser-chunk-line-wrap
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/python/lftp/job_status_parser.py`:
- Around line 243-247: The chunk_wrap_pattern regex in
src/python/lftp/job_status_parser.py requires at least one
non-backtick/non-backslash character before the closing quote, causing failures
for quote-only wrapped tails; update the chunk_wrap_pattern so the leading
characters are optional but still disallow lines starting with backtick or
backslash (e.g., change the prefix to use a non-capturing optional group like
(?:[^`\\].*)? before the closing quote), preserving the rest of the pattern (the
"'\s+at\s+\d+\s..." sequence, optional "(?:\(\d+%\)\s+)?", optional speed group
"(?:(?:\d+\.?\d*\s?({sz}))\/s\s+)?", optional eta "(?:eta:({eta})\s+)?", and
final "\s*\[.*\]$"); modify the chunk_wrap_pattern variable accordingly so lines
that start exactly at the quote boundary match while still rejecting
backtick/backslash-prefixed lines.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 608d1546-b23a-4881-b255-ce9fc53fd503

📥 Commits

Reviewing files that changed from the base of the PR and between ad3b590 and 5ef56e1.

📒 Files selected for processing (2)
  • src/python/lftp/job_status_parser.py
  • src/python/tests/unittests/test_lftp/test_job_status_parser.py

Long filenames cause lftp chunk progress lines to wrap across PTY
boundaries, producing tail fragments like:
  tmos.7.1.DV.HDR.H.265-TheFarm.mkv' at 22283455338 (0%) 427.6K/s eta:28m [Receiving data]

The parser didn't recognize these fragments (missing leading backtick)
and raised ValueError, crashing the controller.

Add chunk_wrap_m pattern to match these fragments and skip them
alongside existing orphan/partial progress line handling.

Add 3 regression tests covering: fragment after job, bare fragment,
and fragment with [Connecting...] status.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@nitrobass24 nitrobass24 force-pushed the fix/parser-chunk-line-wrap branch from 5ef56e1 to 6a204d0 Compare March 18, 2026 14:28
@nitrobass24 nitrobass24 merged commit 0e19eb5 into develop Mar 18, 2026
11 checks passed
@nitrobass24 nitrobass24 deleted the fix/parser-chunk-line-wrap branch March 18, 2026 14:49
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.

1 participant