Skip to content

Raise ParameterError when writing a topology with missing term types - #1440

Merged
swails merged 2 commits into
ParmEd:masterfrom
barlowa124:missing-term-type-error-1423
Nov 5, 2026
Merged

swails merged 2 commits into
ParmEd:masterfrom
barlowa124:missing-term-type-error-1423

Conversation

@barlowa124

Copy link
Copy Markdown
Contributor

Summary

Saving an AmberParm/ChamberParm whose valence terms have type=None failed with AttributeError: 'NoneType' object has no attribute 'used' deep inside remake_parm. This happens after parmed.openmm.load_topology when the OpenMM System drops terms, for example constraints=HBonds removes constrained bonds from HarmonicBondForce so Bond objects exist in the topology but never get a BondType. The reporter of #1423 hit exactly this and could not tell which object was missing parameters.

AmberParm._xfer_bond_info, _xfer_angle_info, _xfer_dihedral_info, _xfer_cmap_properties, and the ChamberParm Urey-Bradley/improper counterparts now raise ParameterError naming the offending term instead of crashing on .used.

Test plan

  • New regression test test_write_parm_missing_bond_type nulls bonds[0].type on ala_ala_ala.parm7 and asserts ParameterError with "no bond type". Fails with AttributeError on unfixed code, passes after.
  • pytest test/test_parmed_amber.py: 86 passed, 6 skipped (test_optimized_reader deselected. It needs the uncompiled _rdparm extension and fails identically on master).

Previously, saving a parmtop/ChamberParm whose bonds, angles, dihedrals,
CMAPs, Urey-Bradleys, or impropers had type=None (for example after
parmed.openmm.load_topology with constraints=HBonds, where OpenMM
removes constrained bonds from the System) failed with
AttributeError: 'NoneType' object has no attribute 'used'. Raise a
ParameterError naming the offending term instead.

Closes ParmEd#1423
@swails
swails merged commit d014a44 into ParmEd:master Nov 5, 2026
3 checks passed
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.

2 participants