Skip to content

fix(METADATA): leniently stringify non-string search settings (ProteomicsLFQ mzTab crash) - #9666

Merged
timosachsenberg merged 1 commit into
developfrom
fix/search-engine-settings-string-conversion
Jun 25, 2026
Merged

timosachsenberg merged 1 commit into
developfrom
fix/search-engine-settings-string-conversion

Conversation

@timosachsenberg

@timosachsenberg timosachsenberg commented Jun 25, 2026 •

Copy link
Copy Markdown
Contributor

Problem

ProteomicsLFQ aborts during mzTab export when the search settings include a non-string value (e.g. an integer missed_cleavages):

Error: Unexpected internal error (Could not convert non-string DataValue of type 'Int' and value '2' to string)

The abort happens after the consensusXML has already been written, so -out_cxml succeeds but -out (mzTab) and -out_msstats are left empty/missing.

Root cause

ProteinIdentification::getSearchEngineSettingsAsPairs() built the std::string member of a (key, value) pair directly from a DataValue:

result.emplace_back(StringUtils::substr(mvkey, se.size()+1), params.getMetaValue(mvkey));

Since the String class was removed, DataValue::operator std::string() is strict and throws ConversionError on any non-STRING_VALUE type (the lenient String(const DataValue&) stringification is gone). The first Int setting (e.g. Comet:missed_cleavages = 2) therefore throws.

Call path:

MzTabFile::store(…, ConsensusMap) -> CMMzTabStream ctor
  -> mapBetweenRunAndSearchEngines_ -> getSearchEngineSettingsAsPairs -> DataValue::operator std::string()  [throws]

The other settings in the same function already use StringUtils::toStr; this one branch was missed during the String removal.

Fix

Use the lenient StringUtils::toStr() (the documented replacement for String(const DataValue&)), matching the rest of the function.

Test

Adds a ProteinIdentification_test section for getSearchEngineSettingsAsPairs covering Int / Double / String settings (the method had no prior coverage).

Verification

ProteomicsLFQ on a real dataset now exits 0 and writes a fully populated mzTab (PRT/PSM/PEP) + MSstats where it previously crashed. Surfaced while benchmarking match-between-runs for #9647 (PIP-ECHO), but the bug is independent of that work.

🤖 Generated with Claude Code

https://claude.ai/code/session_016rawZsiVUCJjzyXTqkkrWK

Summary by CodeRabbit

  • Bug Fixes

    • Improved handling of search engine metadata so settings are consistently returned as string pairs, even when some stored values are not already strings.
    • Prevented errors when converting non-string metadata values, making search engine settings export more reliable.
  • Tests

    • Added coverage for search engine settings conversion, including non-string metadata values and expected output formatting.

getSearchEngineSettingsAsPairs() built a std::string pair member directly from
params.getMetaValue(key). Since the String class was removed,
DataValue::operator std::string() is strict and throws on any non-string type.
The first Int setting (e.g. Comet:missed_cleavages=2) therefore threw
"Could not convert non-string DataValue of type 'Int'", crashing ProteomicsLFQ's
streaming mzTab export (MzTabFile::store(ConsensusMap) -> CMMzTabStream ->
mapBetweenRunAndSearchEngines_) after the consensusXML had already been written.

Convert explicitly with StringUtils::toStr(), matching the other settings in the
same function. Adds a ProteinIdentification_test regression covering Int/Double/
String settings (the method was previously untested).

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_016rawZsiVUCJjzyXTqkkrWK
@coderabbitai

coderabbitai Bot commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

ProteinIdentification::getSearchEngineSettingsAsPairs now converts prefixed meta values with explicit string conversion. The new test covers Comet settings, including an integer meta value, and checks the returned string pairs and tolerance-related entries.

Changes

ProteinIdentification search-engine settings

Layer / File(s) Summary
Lenient meta-value conversion
src/openms/source/METADATA/ProteinIdentification.cpp, src/tests/class_tests/openms/source/ProteinIdentification_test.cpp
ProteinIdentification::getSearchEngineSettingsAsPairs now uses StringUtils::toStr for prefixed meta values, and the new unit test checks string output for Comet meta values including an integer.

Poem

A bunny hopped through metadata bright,
Converting each value just right.
With Comet in tow,
The string pairs now flow,
And tests give a cheerful green light. 🐰

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.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 clearly matches the main change: lenient stringification of non-string metadata to fix the ProteomicsLFQ mzTab crash.
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.

✏️ 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/search-engine-settings-string-conversion

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
src/tests/class_tests/openms/source/ProteinIdentification_test.cpp (1)

376-378: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Use TEST_TRUE for boolean assertions.

These assert booleans against true; prefer TEST_TRUE for clarity. The missed/enzyme checks can also assert string equality directly.

♻️ Proposed change
-	TEST_EQUAL(missed == "2", true)
-	TEST_EQUAL(enzyme == "Trypsin", true)
-	TEST_EQUAL(have_tol, true)
+	TEST_EQUAL(missed, "2")
+	TEST_EQUAL(enzyme, "Trypsin")
+	TEST_TRUE(have_tol)

As per coding guidelines: "Prefer TEST_TRUE(expr) and TEST_FALSE(expr) over TEST_EQUAL(expr, true) and TEST_EQUAL(expr, false) for boolean assertions".

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/tests/class_tests/openms/source/ProteinIdentification_test.cpp` around
lines 376 - 378, The assertions in ProteinIdentification_test should use the
boolean-specific test macros instead of comparing against true. Update the
checks around the missed, enzyme, and have_tol values in the relevant test case
to use TEST_TRUE for boolean conditions, and prefer direct string equality
assertions for the missed and enzyme string values where applicable. Refer to
the existing test block in ProteinIdentification_test and keep the same intent
while replacing TEST_EQUAL(..., true) with the clearer assertions.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@src/tests/class_tests/openms/source/ProteinIdentification_test.cpp`:
- Around line 376-378: The assertions in ProteinIdentification_test should use
the boolean-specific test macros instead of comparing against true. Update the
checks around the missed, enzyme, and have_tol values in the relevant test case
to use TEST_TRUE for boolean conditions, and prefer direct string equality
assertions for the missed and enzyme string values where applicable. Refer to
the existing test block in ProteinIdentification_test and keep the same intent
while replacing TEST_EQUAL(..., true) with the clearer assertions.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 7aa8bd03-a0da-421d-9698-ee73ed8c12e0

📥 Commits

Reviewing files that changed from the base of the PR and between 80a1854 and 7755902.

📒 Files selected for processing (2)
  • src/openms/source/METADATA/ProteinIdentification.cpp
  • src/tests/class_tests/openms/source/ProteinIdentification_test.cpp

@timosachsenberg
timosachsenberg merged commit 0791613 into develop Jun 25, 2026
16 checks passed
@timosachsenberg
timosachsenberg deleted the fix/search-engine-settings-string-conversion branch June 25, 2026 18:57
timosachsenberg added a commit that referenced this pull request Jun 26, 2026
Documents PRs that landed after the last CHANGELOG update (#9656):
- #9647 PIP-ECHO match-between-runs algorithm in ProteomicsLFQ
- #9666 ProteomicsLFQ mzTab crash on non-string search settings
- #9658 ProteinQuantifier wrong per-file split on merged ID runs (fixes #5518)
- #9664 Math::quantile1st/3rd crash on 1–2 element inputs (fixes #9659)


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

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