You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently the DefaultParamHandler allows a very inconsistent access to the managed parameters. We should consider enforcing a certain access pattern which that defines exactly when the parameters should be transferred from the defaultparamhandler to members.
A solution would be
make param_ and getParamters() private
define updateMembers_(const Param& param) = 0 in DefaultParamHandler
With this every class that inherits from DefaultParamHandler would need to implement the method and it also would be the only possibility to access the parameters. A similar solution could be used for setDefaults.
Triage of this 2013 issue against current develop.
The diagnosis still holds, the proposed remedy does not
Access to the managed parameters is still as inconsistent as described:
classes deriving directly from DefaultParamHandler
113
classes implementing updateMembers_()
108 (85 non-empty)
direct reads of the protected param_
~1500, in 163 files
direct writes to param_, bypassing setParameters()/checkDefaults()
~71
But the specific fix proposed here is not workable at that scale, which is what #8278 ran into:
getParameters() cannot be made private. It is public API used by TOPP tools, the GUI and pyOpenMS (exposed on the DefaultParamHandler base in the nanobind bindings).
Making param_ private means touching those 163 files.
updateMembers_() = 0 makes DefaultParamHandler abstract and forces ~100 empty overrides — churn with no semantic gain, and it breaks DefaultParamHandler_test and any direct instantiation.
What the design flaw actually costs today
The part that causes real bugs is not the visibility of param_, it is this line of DefaultParamHandler.h:
Call updateMembers_() at the end of the derived classes' copy constructor and assignment operator.
Nothing enforces that. Six classes get it wrong right now — their copy constructor and operator= forward to the base (so param_ is copied) but never re-sync the members updateMembers_() caches, none of which have in-class initializers:
class
cached members left indeterminate on copy
TheoreticalSpectrumGenerator
30
TheoreticalSpectrumGeneratorXLMS
25
NucleicAcidSpectrumGenerator
23
SimpleTSGXLMS
13
SpectrumAnnotator
8
Normalizer
1 — method_ stays empty, so a copy throws InvalidValue("Method not known", "")
The two XLMS generators additionally left loss_db_ empty, so a copy threw std::out_of_range from loss_db_.at() whenever losses were requested. All six expose their copy constructor to Python (nb::init<const T&>(), __copy__, __deepcopy__ in bind_misc.cpp), so copy.deepcopy() of a configured object was affected too.
The existing copy tests did not catch any of it because they only compared getParameters() — which the base class copies correctly in every case.
Fix
Branch claude/openms-issue-532-vxjlrw (commit da4f498). All six copy operations become = default: the compiler-generated versions copy param_ and the cached members together, which is exactly the state updateMembers_() would have produced, since none of these six do anything but assign scalars from param_. The hand-written contract disappears rather than being restated. Also resets TheoreticalSpectrumGenerator::isotope_model_ for isotope_model=none, which updateMembers_() previously left unassigned on the default path. The copy tests now configure an object, copy it, and compare what the copy actually produces.
Closing: the redesign proposed here is not being pursued, and the concrete defect behind it is addressed on that branch. Worth opening a fresh, narrower issue if someone wants to revisit the API itself.
Correction: the branch head is 5f8978d, not da4f498 (the commit was amended).
Since then it has been built and tested: the six class tests pass with the fix, all six fail with the source change reverted and the new tests kept, and 25 dependent class tests (OPXL, DIA scoring, PScore/HyperScore/MorpheusScore, Deisotoper, FragmentIndex, Tagger, SpectrumAlignment, …) pass.
Activity
timosachsenberg commentedon Sep 5, 2026
Triage of this 2013 issue against current
develop.The diagnosis still holds, the proposed remedy does not
Access to the managed parameters is still as inconsistent as described:
DefaultParamHandlerupdateMembers_()param_param_, bypassingsetParameters()/checkDefaults()But the specific fix proposed here is not workable at that scale, which is what #8278 ran into:
getParameters()cannot be made private. It is public API used by TOPP tools, the GUI and pyOpenMS (exposed on theDefaultParamHandlerbase in the nanobind bindings).param_private means touching those 163 files.updateMembers_() = 0makesDefaultParamHandlerabstract and forces ~100 empty overrides — churn with no semantic gain, and it breaksDefaultParamHandler_testand any direct instantiation.What the design flaw actually costs today
The part that causes real bugs is not the visibility of
param_, it is this line ofDefaultParamHandler.h:Nothing enforces that. Six classes get it wrong right now — their copy constructor and
operator=forward to the base (soparam_is copied) but never re-sync the membersupdateMembers_()caches, none of which have in-class initializers:TheoreticalSpectrumGeneratorTheoreticalSpectrumGeneratorXLMSNucleicAcidSpectrumGeneratorSimpleTSGXLMSSpectrumAnnotatorNormalizermethod_stays empty, so a copy throwsInvalidValue("Method not known", "")The two XLMS generators additionally left
loss_db_empty, so a copy threwstd::out_of_rangefromloss_db_.at()whenever losses were requested. All six expose their copy constructor to Python (nb::init<const T&>(),__copy__,__deepcopy__inbind_misc.cpp), socopy.deepcopy()of a configured object was affected too.The existing copy tests did not catch any of it because they only compared
getParameters()— which the base class copies correctly in every case.Fix
Branch
claude/openms-issue-532-vxjlrw(commit da4f498). All six copy operations become= default: the compiler-generated versions copyparam_and the cached members together, which is exactly the stateupdateMembers_()would have produced, since none of these six do anything but assign scalars fromparam_. The hand-written contract disappears rather than being restated. Also resetsTheoreticalSpectrumGenerator::isotope_model_forisotope_model=none, whichupdateMembers_()previously left unassigned on the default path. The copy tests now configure an object, copy it, and compare what the copy actually produces.Closing: the redesign proposed here is not being pursued, and the concrete defect behind it is addressed on that branch. Worth opening a fresh, narrower issue if someone wants to revisit the API itself.
Generated by Claude Code
[FIX] Keep DefaultParamHandler-cached members in sync when copying (#532
[FIX] Keep DefaultParamHandler-cached members in sync when copying (#532
timosachsenberg commentedon Sep 5, 2026
Correction: the branch head is
5f8978d, notda4f498(the commit was amended).Since then it has been built and tested: the six class tests pass with the fix, all six fail with the source change reverted and the new tests kept, and 25 dependent class tests (OPXL, DIA scoring, PScore/HyperScore/MorpheusScore, Deisotoper, FragmentIndex, Tagger, SpectrumAlignment, …) pass.
Generated by Claude Code
[FIX] Keep DefaultParamHandler-cached members in sync when copying (#532
Update CHANGELOG: DefaultParamHandler copy fix and bioconda lint fix (#…