Repository navigation
[FORMAT] Fix 'required'/'fdr_type' attributes parsed into the wrong variable - #9764
Merged
Merged
Conversation
Contributor
📝 WalkthroughWalkthroughChangesXML metadata parsing fixes
Possibly related issues
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
📋 Issue PlannerBuilt with CodeRabbit's Coding Plans for faster development and fewer bugs. View plan used: ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
timosachsenberg
force-pushed
the
fix/9763-paramxml-required-attribute
branch
from
July 20, 2026 14:44
0165b69 to
0a681f0
Compare
…ariable Two instances of the same defect: an optionalAttributeAs*_ call whose output argument is a different variable than the one declared for it. Because optionalAttributeAsString_ leaves its output untouched when the attribute is absent, the stale value of a previously parsed attribute is what gets tested. ParamXMLHandler (ITEM branch) 'required' was parsed into advanced_string, which was also the variable tested, so an <ITEM advanced="true"> that omitted the optional 'required' attribute was silently tagged "required". The ITEMLIST branch, added one day later in fc5ce40, already did this correctly and is unchanged apart from a stale //advanced comment. Introduced in 906c632 (2013, 1.6.2 schema). Current OpenMS writers do not produce affected files: ParamXMLFile and ParamCTDFile always emit required="true"/"false" explicitly. The faulty branch is reached by hand-written and third-party INI/CTD files, and by OpenMS INIs written against the Param 1.0-1.2 schemas, which defined 'advanced' but had no 'required' attribute at all. A load/store round trip persists the spurious tag. Ordinary TOPP execution is unaffected because ParameterInformation::required comes from registration, not from the loaded INI; the visible effects are INIFileEditor/ParamEditor highlighting, and pyOpenMS CTDsupport making a parameter mandatory when an affected loaded Param is used to build a CTDopts model. XQuestResultXMLHandler (search_hit branch) 'fdr_type' was parsed into xprophet_f while the guard tested !fdr_type.empty() on a string that was never written, making the guard unconditionally false. XFDR:fdr_type could therefore never be read back from a .xquest.xml file although XFDRAlgorithm sets it and the writer emits it. Tests New Param_advanced_no_required.ini fixture covers representative advanced/required combinations plus an ITEMLIST control, loaded directly rather than produced by the writer, which always emits the attribute and so cannot expose the bug. The pre-existing fixtures miss it for two different reasons: Param_pre16_update.ini uses tags="advanced" with no 'advanced' attribute, and Param_post16_update.ini carries an explicit required="false". xprophet_f/fdr_type added to one hit in the xquest fixture, asserted after the initial load and after the store/load round trip. The hit is located by its OpenPepXL:id rather than by index so the assertions do not depend on the order in which load() groups hits, and the match count is asserted too. Both tests were confirmed to fail against the unfixed sources and pass with them. A scan of src/tests, share and src/pyOpenMS found no other data file with an <ITEM advanced="true"> lacking 'required', and no tool-input .xquest.xml carrying fdr_type, so no reference outputs change. fixes #9763 fixes #9766 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
timosachsenberg
force-pushed
the
fix/9763-paramxml-required-attribute
branch
from
July 20, 2026 14:49
0a681f0 to
d2fbb5c
Compare
1 task done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #9763.
Also fixes #9766 (the XQuest defect below, filed separately after review flagged it as out of scope for #9763).
Two instances of the same defect shape: an
optionalAttributeAs*_call whose output argument is a different variable than the one declared for it. SinceoptionalAttributeAsString_leaves its output untouched when the attribute is absent (XMLHandler.h#L422-L431), the stale value of a previously parsed attribute is what ends up being tested.1.
ParamXMLHandler, ITEM branch — #9763An
<ITEM advanced="true">that omits the optionalrequiredattribute is silently taggedrequired. TheITEMLISTbranch — added one day later infc5ce40ece, "[FIX] addendum to [11567], fixed handling of item lists" — already did this correctly and is unchanged apart from a stale//advancedcomment. Introduced in906c632d73(2013, the 1.6.2 schema update), so this has been present for ~13 years.Reproduced against a build before fixing, full matrix through
ParamXMLFile().load:advancedrequired"true"advanced,required"true""false"advanced"true""true"advanced,required"false""true"required"false""false"A load/store round trip persists it. The same fixture gives a clean A/B, identical input through the two branches:
Scope. Current OpenMS writers do not produce affected files:
ParamXMLFile::writeXMLToStreamandParamCTDFilealways emitrequired="true"|"false"explicitly. The faulty branch is reached by hand-written and third-party INI/CTD files, and by OpenMS INIs written against the Param 1.0–1.2 schemas, which definedadvancedas an ITEM attribute but had norequiredattribute at all (Param_1_0.xsd,Param_1_1.xsd,Param_1_2.xsd).requiredis optional perParam_1_8_0.xsd(default="false"), and the default is not injected on load since parsing does not run schema validation.Ordinary TOPP execution is unaffected:
ParameterInformation::requiredis built at registration from in-memory defaults (TOPPBase.cpp:953), not from the loaded INI, and noregisterFullParam_call site passes a file-loadedParam.Param::checkDefaultsnever inspects tags either. The visible effects are the INIFileEditor/ParamEditorrequired-highlight,ToolsDialogoutput pre-selection, andsrc/pyOpenMS/pyTOPP/CTDsupport.py:18, which turns the tag into a mandatory CTDopts argument when an affected loadedParamis used to build the model.2.
XQuestResultXMLHandler, search_hit branch — #9766, found during reviewStrictly worse:
fdr_typewas never written, so!fdr_type.empty()was unconditionally false and the body unreachable.XFDR:fdr_typecould never be restored from a.xquest.xml, even thoughXFDRAlgorithm.cpp:221sets it and the writer emits it atXQuestResultXMLHandler.cpp:1152— write-only metadata.XFDRAlgorithm_testasserts the value exists, but in memory after the algorithm runs, never through the reader.Tests
New
Param_advanced_no_required.inicovers representative combinations plus an ITEMLIST control, loaded directly rather than produced by the writer. The pre-existing fixtures miss this for two different reasons, which is why a writer round trip alone would not be enough:Param_pre16_update.iniusestags="advanced"with noadvancedattribute at all, andParam_post16_update.inicarries an explicitrequired="false".xprophet_f/fdr_typeadded to one hit in the xquest fixture, asserted after the initial load and after the store/load round trip, withXFDR:used_for_FDRas the control. The hit is located by itsOpenPepXL:idrather than by index —load()regroups hits viacombineTopRanksFromPairs, so index 0 is deterministic but incidental — and the match count is asserted so the test fails loudly if the fixture stops carrying the attributes.Both tests were confirmed to fail against the unfixed sources (only the targeted assertions failed; every control passed) and to pass with them. A scan of
src/tests,shareandsrc/pyOpenMSfound exactly one<ITEM advanced="true">lackingrequiredin the whole repo — the new fixture — and no tool-input.xquest.xmlcarryingfdr_type, so no reference outputs change. All 50Param|XQuest|XFDR|OpenPepXL|TOPPBasetests pass locally.Not addressed
QcMLFile.cpp:820-825has the same family of hazard:qp_is a member whose reset at:942sits insideif (!(qp_.cvAcc == "MS:1000577" && parent_tag == "setQuality")), so a following<qualityParameter>can inheritvalue/unitAcc/unitRef/flagfor any it omits. Left out because fixing it changes qcML parsing semantics rather than restoring clearly intended behavior — happy to split it off into its own issue.Review notes
Reviewed with an independent model pass, which corrected two claims now fixed above: the original text said only hand-written/third-party files were affected (it missed the Param 1.0–1.2 schema era), and overstated how directly the CTDsupport path is reached. It also flagged the index-0 coupling in the xquest test, now replaced with an id-anchored lookup. No correctness issue was found in either source fix.
🤖 Generated with Claude Code
Summary by CodeRabbit
requiredattributes in parameter configuration files forITEMentries, preventing incorrect persistence ofrequired="true"during load/save round-trips.fdr_typeis correctly captured asXFDR:fdr_type.XFDR:fdr_typeandXFDR:used_for_FDRacross XQuest result file reloads.requiredscenarios and XFDR metadata preservation (including store/load round-trip).