Skip to content

Fix parser crash on unrecognized lftp status lines (#253)#258

Merged
nitrobass24 merged 1 commit intomasterfrom
fix/parser-crash-receiving-data
Mar 12, 2026
Merged

Fix parser crash on unrecognized lftp status lines (#253)#258
nitrobass24 merged 1 commit intomasterfrom
fix/parser-crash-receiving-data

Conversation

@nitrobass24
Copy link
Owner

@nitrobass24 nitrobass24 commented Mar 12, 2026

Summary

  • The lftp job status parser crashed on unrecognized lines like 3.0K/s eta:3m [Receiving data], which lftp emits during initial connection/data reception
  • After 3 consecutive parse failures, the error propagated and killed the Docker container
  • Changed both crash points in __parse_jobs to log a warning and skip unrecognized lines instead of throwing ValueError

Fixes #253

Test plan

  • Added test_unrecognized_status_line_skipped — unrecognized line after a valid job is skipped, valid job still parsed
  • Added test_bare_unrecognized_line_skipped — bare unrecognized line with no valid jobs returns empty list
  • Verify container no longer crashes when lftp emits [Receiving data] status lines

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes

    • Improved job status parsing resilience: stray progress lines are now detected, logged, and skipped instead of causing errors, so parsing continues reliably.
  • Tests

    • Added unit tests covering skipped orphan progress lines and truly unrecognized lines to prevent regressions and ensure correct parser behavior.

@coderabbitai
Copy link

coderabbitai bot commented Mar 12, 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: 3f195ad4-6ffa-49d2-840f-4b9f9a5a161e

📥 Commits

Reviewing files that changed from the base of the PR and between fc296e1 and 63ea792.

📒 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

Changed LftpJobStatusParser.__parse_jobs from a staticmethod to an instance method and made the parser tolerant of "orphan" progress lines by detecting and skipping them (logging a warning) instead of raising on unrecognized lines. Added tests covering orphan progress and truly unrecognized lines.

Changes

Cohort / File(s) Summary
Job Status Parser
src/python/lftp/job_status_parser.py
Converted __parse_jobs to an instance method (self), added orphan_progress_m regex and logic to detect/skip orphan progress lines (log warning instead of raising), adjusted final unrecognized-line handling and added comments for the new flow.
Parser Unit Tests
src/python/tests/unittests/test_lftp/test_job_status_parser.py
Added three tests: test_orphan_progress_line_skipped_after_job, test_bare_orphan_progress_line_skipped, and test_truly_unrecognized_line_raises to validate skipping of orphan progress lines and raising on truly unrecognized lines.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

bug

Poem

🐰 I hopped through logs both dark and light,
Found stray progress lines that gave a fright.
Now I skip them with a gentle nudge,
Warnings whisper, no more judge.
Hooray — the parser sleeps tonight. 🥕✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: fixing a parser crash on unrecognized lftp status lines, which is the primary objective of this pull request.
Linked Issues check ✅ Passed The PR addresses all coding requirements from issue #253: making the parser skip unrecognized lines instead of raising errors, preventing crash propagation, and adding test coverage for both orphan progress lines and unrecognized lines.
Out of Scope Changes check ✅ Passed All changes are directly related to fixing the parser crash: converting __parse_jobs to an instance method, adding orphan progress line handling, and adding comprehensive test cases for the new resilience behavior.

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

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/parser-crash-receiving-data
📝 Coding Plan for PR comments
  • Generate coding plan

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: 2

🤖 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 229-231: Replace direct
logging.getLogger("LftpJobStatusParser").warning calls with the parser instance
logger so warnings follow the caller's logger hierarchy: in the __parse_jobs
method (and the similar occurrence at the block around lines 497-499), change
those warnings to self.logger.warning(...) and ensure set_base_logger() provided
logger continues to be used by the class (i.e., reference the instance attribute
self.logger rather than creating a new logger).
- Around line 220-232: The current check in LftpJobStatusParser (around prev_job
/ pget_header_m / mirror_header_m / mirror_fl_header_m) is too broad and
silently skips any unrecognized line; restrict this to only known orphan
progress-line formats by introducing/using a dedicated matcher (e.g.,
orphan_progress_m) and skip only when that regex matches the line, otherwise
treat it as a real parse failure (raise or return an error so the caller
increments __consecutive_status_errors). Apply the same narrowing fix to the
other identical branch around lines 494-499 so only the recognized orphan
progress pattern is suppressed and all other unknown lines propagate as errors;
reference prev_job, pget_header_m, mirror_header_m, mirror_fl_header_m, and the
logger "LftpJobStatusParser" when locating the spots to modify.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 7dedebc9-d52a-41c2-b175-3df4629f2712

📥 Commits

Reviewing files that changed from the base of the PR and between 657d1eb and fc296e1.

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

The lftp job status parser crashed with a ValueError on unrecognized
lines like "3.0K/s eta:3m [Receiving data]", which propagated as
LftpJobStatusParserError and killed the Docker container after 3
consecutive failures.

Changed both crash points in __parse_jobs to log a warning and skip
unrecognized lines instead of raising ValueError. This makes the parser
resilient to unexpected lftp output formats while still parsing all
recognized job statuses.

Fixes #253

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@nitrobass24 nitrobass24 force-pushed the fix/parser-crash-receiving-data branch from fc296e1 to 63ea792 Compare March 12, 2026 01:43
@nitrobass24
Copy link
Owner Author

@CodeRabbit review

@coderabbitai
Copy link

coderabbitai bot commented Mar 12, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

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.

error stopped docker

1 participant