Skip to content

chore(mzml): annotate StaxMzMLParser BOM/prolog errors (Q8)#19

Open
ypriverol wants to merge 1 commit intodevfrom
feat/stax-error-context
Open

chore(mzml): annotate StaxMzMLParser BOM/prolog errors (Q8)#19
ypriverol wants to merge 1 commit intodevfrom
feat/stax-error-context

Conversation

@ypriverol
Copy link
Copy Markdown
Member

Summary

The Stax XML parser raises terse ParseError in XML prolog exceptions when an mzML file carries a UTF-8 BOM or a malformed encoding declaration. This is a recurring onboarding failure mode (see thomasp85/MSGFplus#8) — users see the error but not the fix.

This PR wraps the two Stax parse entry points in StaxMzMLParser.java (buildIndex and preloadAllSpectra) with a helper annotate(XMLStreamException, phase) that:

  • preserves the original exception as the cause (so existing log-matching tooling keeps working)
  • prepends the full mzML file path and the parse phase (index / preload)
  • when the underlying message looks like a BOM / prolog / encoding failure, points the user at ThermoRawFileParser / MSConvert and docs/Troubleshooting.md, including a concrete shell recipe to detect a BOM (head -c 3 file.mzML | xxd).

No behaviour change for well-formed mzML — annotate is only reached on an exception.

Test plan

Not in this PR

Follow-ups from the landscape review queue:

🤖 Generated with Claude Code

…e context (Q8)

The Stax XML parser raises terse "ParseError in XML prolog" exceptions
when an mzML file has a byte-order mark or malformed encoding
declaration — a recurring onboarding failure reported in
thomasp85/MSGFplus#8. Users see the message but not the fix.

Wraps both parse entry points (buildIndex, preloadAllSpectra) in
catches that:
  - preserve the original XMLStreamException as the cause
  - prepend the full mzML file path and the parse phase
  - when the underlying message looks like a BOM / prolog / encoding
    failure, point the user at ThermoRawFileParser / MSConvert and
    docs/Troubleshooting.md with a concrete shell command to detect
    a BOM (`head -c 3 file.mzML | xxd`)

No behaviour change for well-formed mzML: annotate() is only reached
on an exception, and the wrapped message still includes the original
parser error verbatim so tooling that matches on Stax substrings
keeps working.

Tests: TestStaxMzMLParserErrorContext (2 cases) feeds BOM-prefixed
and garbage-prolog mzML to the constructor and verifies the wrapped
message is emitted.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 17, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e92c68f3-5780-41fd-a8bc-bbb3d8edd627

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/stax-error-context

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.

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