Skip to content

Fix parser crash: skip unrecognized lines inside job context#293

Merged
nitrobass24 merged 2 commits intodevelopfrom
fix/parser-skip-unrecognized-in-job
Mar 18, 2026
Merged

Fix parser crash: skip unrecognized lines inside job context#293
nitrobass24 merged 2 commits intodevelopfrom
fix/parser-skip-unrecognized-in-job

Conversation

@nitrobass24
Copy link
Owner

@nitrobass24 nitrobass24 commented Mar 18, 2026

Summary

Replaces the whack-a-mole approach to PTY line-wrap fragments with a single rule: skip any unrecognized line when inside a job context.

Problem

PR #290 fixed one specific fragment pattern (filename tails), but production immediately hit two new variants:

  • eta:4m [Receiving data] — line wraps right before the eta value
  • ta:4m [Receiving data] — line wraps mid-word in "eta"

PTY wrapping can break lines at arbitrary byte positions. No finite set of regex patterns can anticipate all possible fragments.

Fix

When prev_job is set (we're parsing lines inside a recognized job), skip any unrecognized line with a warning instead of raising. Lines outside any job context still raise to catch genuinely malformed output.

This is a safer, more general approach than adding specific patterns for each fragment type.

Tests

  • test_unrecognized_line_inside_job_is_skipped — garbage inside job is skipped
  • test_eta_fragment_inside_job_is_skippedeta:4m [Receiving data]
  • test_partial_eta_fragment_inside_job_is_skippedta:4m [Receiving data]
  • test_truly_unrecognized_line_outside_job_raises — garbage with no job context still raises
  • All 62 parser tests pass

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes

    • Improved parser resilience: unexpected fragments encountered while parsing an active job are now skipped with a warning instead of causing a failure; strict validation for truly unrecognized lines outside job contexts is preserved.
  • Tests

    • Expanded unit tests to cover wrapped/fragmented progress lines and confirm skip vs. raise behavior.

Instead of adding specific regex patterns for each PTY line-wrap
variant (filename tails, partial eta, mid-word fragments), skip
ANY unrecognized line when we're inside a job context (prev_job is
set). Lines outside a job context still raise.

This eliminates the whack-a-mole pattern of adding regexes for
each new fragment type. PTY wrapping can produce arbitrary break
points that no fixed set of patterns can anticipate.

Fragments seen in production:
  - "eta:4m [Receiving data]" (wrap before eta)
  - "ta:4m [Receiving data]" (wrap mid-word)
  - "tmos.7.1...mkv' at 22283455338 (0%) ..." (filename tail)

Add 4 tests: unrecognized-in-job skipped, eta fragment, partial
eta fragment, unrecognized-outside-job still raises.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@coderabbitai
Copy link

coderabbitai bot commented Mar 18, 2026

Caution

Review failed

Pull request was closed or merged during review

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: 7741ac0e-b7db-4a0f-b290-b1002df22dc3

📥 Commits

Reviewing files that changed from the base of the PR and between 4fe277c and 878ae49.

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

📝 Walkthrough

Walkthrough

The parser now skips unrecognized lines when parsing inside an active job (prev_job != None), logging a warning instead of raising ValueError. Unrecognized lines outside any job context continue to raise errors. Tests were expanded to cover PTY-wrapped and fragmented progress-line edge cases.

Changes

Cohort / File(s) Summary
Core Parser Logic
src/python/lftp/job_status_parser.py
Adjust __parse_jobs to tolerate and skip unrecognized/fragmented lines when currently inside a parsed job (prev_job present), logging a warning; preserve error raising for unrecognized lines outside job context.
Test Suite
src/python/tests/unittests/test_lftp/test_job_status_parser.py
Replace single error-test with multiple tests verifying: skipped unrecognized lines inside a job, skipped ETA and partial-ETA fragments inside a job, and that truly unrecognized lines outside a job still raise an error.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

bug

Poem

🐰 I hopped through logs with careful ears,
Skipping broken whispers, easing fears.
Inside each job I nibble stray lines clean,
Outside the bounds, I sound the warning keen.
Happy parsing — carrots for the routine!

🚥 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 accurately summarizes the main change: fixing a parser crash by skipping unrecognized lines inside job contexts. It directly corresponds to the core modification in the code and test files.
Docstring Coverage ✅ Passed Docstring coverage is 83.33% 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-skip-unrecognized-in-job
📝 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/tests/unittests/test_lftp/test_job_status_parser.py`:
- Around line 1589-1621: The file test_job_status_parser.py has formatting
issues flagged by ruff; run ruff format on that test file to fix
whitespace/formatting so CI passes — e.g. format the file containing the test
methods test_unrecognized_line_inside_job_is_skipped,
test_eta_fragment_inside_job_is_skipped,
test_partial_eta_fragment_inside_job_is_skipped, and
test_truly_unrecognized_line_outside_job_raises by running `ruff format` (or
your editor’s ruff integration) on
src/python/tests/unittests/test_lftp/test_job_status_parser.py, then re-run
tests/CI.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 6a2c0480-108a-4b1f-a071-8bd2ee6d920c

📥 Commits

Reviewing files that changed from the base of the PR and between 0e19eb5 and 4fe277c.

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

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@nitrobass24 nitrobass24 merged commit d761a68 into develop Mar 18, 2026
10 of 11 checks passed
@nitrobass24 nitrobass24 deleted the fix/parser-skip-unrecognized-in-job branch March 18, 2026 17:00
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