Skip to content

[FIX,TOPP] MSstatsConverter: return ILLEGAL_PARAMETERS instead of aborting (SIGABRT) on an unidentifiable input - #9901

Merged
timosachsenberg merged 1 commit into
developfrom
fix/msstatsconverter-throw-int
Aug 10, 2026
Merged

timosachsenberg merged 1 commit into
developfrom
fix/msstatsconverter-throw-int

Conversation

@timosachsenberg

@timosachsenberg timosachsenberg commented Aug 9, 2026 •

Copy link
Copy Markdown
Contributor

Summary

MSstatsConverter aborts with SIGABRT instead of returning an error when handed an input file whose type OpenMS cannot determine.

$ MSstatsConverter -in unidentifiable.dat -in_design design.tsv -out out.csv
Warning: Could not determine format of input file 'unidentifiable.dat'!
MSstatsConverter.cpp(198): FATAL: Input type is not consensusXML!
terminate called after throwing an instance of 'int'
Aborted (core dumped)          # exit 134

fatalErrorIf_ took its exit code as an int and threw it, while main_ catches const ExitCodes&. C++ exception matching does not convert an int to an enum, and TOPPBase has no catch(...), so the throw escaped main().

Fix: one type change — the helper takes ExitCodes, so the thrown object matches the existing handler. Verified end to end: exit 134 → exit 6 (ILLEGAL_PARAMETERS).

This is not a regression

It has been on develop since the tool was merged in #3485 (ab6cf7ed75d9, 2018-05-30). The defect was introduced two months earlier by 04e4be810495, which did:

- catch(int)
+ catch(const ExitCodes &exit_code)
- static void _conditionalFatalError(const String & message, bool error_condition)
+ static void _conditionalFatalError(const String & message, bool error_condition, int exit_code)
- throw 1;
+ throw exit_code;

The pre-merge feature-branch version — catch(int) matching throw 1 — was correct, and is the only version that ever worked. It never reached develop.

Why it went unnoticed for eight years

The path is narrow, not unreachable. TOPPBase has warned rather than refused on an undeterminable input type since ~2008, but FileHandler::getType sniffs content as well as extension:

input result
valid .consensusXML works
.mzML / .tsv (recognized, wrong) clean Invalid parameter, exit 6, before main_ runs
consensusXML content renamed .dat identified by content — processed normally
unidentifiable by both extension and content the crash

Only the last row reaches fatalErrorIf_, and no test supplied such a file.

Regression test

TOPP_MSstatsConverter_unknown_input_type asserts the exact exit code, via a new check_exit_code.cmake helper.

This mattered: neither existing ctest mechanism can express the assertion.

  • WILL_FAIL only distinguishes zero from non-zero, so it treats a crash and a clean error alike — it would have passed on the bug.
  • PASS_REGULAR_EXPRESSION ignores the exit code entirely, and the FATAL: line is printed in both cases.

Confirmed to fail on purpose — restoring the int gives:

Expected exit code 6, got 'Subprocess aborted'.

All 9 MSstatsConverter TOPP tests pass with the fix.

Scope

TriqlerConverter had the identical copy-paste defect; it is removed in #9898. A repo-wide sweep found no other TOPP tool throwing a numeric type without a matching handler (MSFraggerAdapter throws ints but catches them).

The new check_exit_code.cmake is reusable for any test where the specific exit code is the assertion.

🤖 Generated with Claude Code

https://claude.ai/code/session_01S7QNzj4dhRnX5htcHZFmDm

Summary by CodeRabbit

  • Bug Fixes

    • MSstatsConverter now exits gracefully with ILLEGAL_PARAMETERS when it cannot determine the input file type, instead of crashing.
    • Improved handling of command-line errors to return the correct exit status.
  • Tests

    • Added regression coverage to verify the expected exit code and diagnostic behavior.

…rting on an unidentifiable input

fatalErrorIf_ took its exit code as an `int` and threw it, while main_ catches
`const ExitCodes&`. C++ exception matching does not convert an int to an enum, and
TOPPBase has no catch-all, so the throw escaped main() and the process died:

  $ MSstatsConverter -in unidentifiable.dat -in_design design.tsv -out out.csv
  Warning: Could not determine format of input file 'unidentifiable.dat'!
  MSstatsConverter.cpp(198): FATAL: Input type is not consensusXML!
  terminate called after throwing an instance of 'int'
  Aborted (core dumped)          # exit 134

Changing the parameter to ExitCodes makes the thrown object match the existing handler;
the tool now returns ILLEGAL_PARAMETERS (6). Verified: exit 134 -> exit 6.

This is not a regression. It has been on develop since the tool was merged in #3485
(ab6cf7e, 2018-05-30), introduced two months earlier by 04e4be8, which changed
`catch(int)` to `catch(const ExitCodes&)` while making the helper take and throw an int --
the pre-merge feature-branch version, with `catch(int)` matching `throw 1`, was correct
and is the only version that ever worked.

It went unnoticed because the path is narrow, not because it was unreachable: TOPPBase
has warned rather than refused on an undeterminable input type since ~2008, but
FileHandler::getType sniffs content as well as extension, so a recognized-but-wrong file
(.mzML, .tsv) is rejected cleanly before main_ runs, and a misnamed but valid consensusXML
is identified by content and processed normally. Only a file unidentifiable by BOTH
extension and content reaches fatalErrorIf_.

Regression test: TOPP_MSstatsConverter_unknown_input_type asserts the EXACT exit code via
a new check_exit_code.cmake helper. ctest's WILL_FAIL cannot express this -- it treats a
crash and a clean error alike, so it would have passed on the bug -- and
PASS_REGULAR_EXPRESSION ignores the exit code entirely (the FATAL line is printed in both
cases). Confirmed to fail on purpose: with the int restored the test reports
"Expected exit code 6, got 'Subprocess aborted'".

TriqlerConverter had the identical copy-paste defect; it is removed in #9898. A repo-wide
sweep found no other TOPP tool throwing a numeric type without a matching handler
(MSFraggerAdapter throws ints but catches them).

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01S7QNzj4dhRnX5htcHZFmDm
@timosachsenberg
timosachsenberg force-pushed the fix/msstatsconverter-throw-int branch from 8d00d11 to a97d20e Compare August 9, 2026 21:20
@coderabbitai

coderabbitai Bot commented Aug 9, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: c1842e46-cb45-4f7d-8ff8-5f306f34bc9e

📥 Commits

Reviewing files that changed from the base of the PR and between 1e52bcb and a97d20e.

⛔ Files ignored due to path filters (1)
  • src/tests/topp/MSstatsConverter_unknown_type_in.dat is excluded by !**/*.dat
📒 Files selected for processing (4)
  • CHANGELOG
  • src/tests/topp/CMakeLists.txt
  • src/tests/topp/check_exit_code.cmake
  • src/topp/MSstatsConverter.cpp

📝 Walkthrough

Walkthrough

MSstatsConverter now returns ILLEGAL_PARAMETERS when input type detection fails. A reusable CMake helper and CTest regression test verify exit code 6.

Changes

MSstatsConverter error handling

Layer / File(s) Summary
Align failure handling with ExitCodes
src/topp/MSstatsConverter.cpp, CHANGELOG
fatalErrorIf_ now throws ExitCodes, allowing main_ to return ILLEGAL_PARAMETERS for unidentifiable input types.
Validate the illegal-parameter exit code
src/tests/topp/check_exit_code.cmake, src/tests/topp/CMakeLists.txt
The CMake helper compares exact command exit codes. A CTest verifies that unknown input exits with code 6.

Suggested reviewers: cbielow, ypriverol

Poem

A rabbit found a file type stray,
And helped it exit the proper way.
Six hops marked the error trail,
Tests checked the code without fail.
MSstatsConverter now knows:
Illegal parameters make it close.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main fix: returning ILLEGAL_PARAMETERS instead of aborting for unidentifiable input.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ 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/msstatsconverter-throw-int

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.

@timosachsenberg
timosachsenberg merged commit 532ec3c into develop Aug 10, 2026
34 checks passed
@timosachsenberg
timosachsenberg deleted the fix/msstatsconverter-throw-int branch August 10, 2026 05:29
timosachsenberg added a commit that referenced this pull request Aug 11, 2026
Audited PRs merged since the last CHANGELOG update (#9881): most of
them (#9879, #9880, #9882, #9884, #9886, #9892, #9896, #9898, #9900,
#9901, #9888) already carried their own CHANGELOG entries. Only the
Docker library-stage fix (#9891) was missing one.


Claude-Session: https://claude.ai/code/session_01Jgrv6mFL3oawgLdYs1efPH

Co-authored-by: Claude <[email protected]>
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