Fix NPE in ParticleMathMapping for non-mass-action kinetics#1671
Open
Fix NPE in ParticleMathMapping for non-mass-action kinetics#1671
Conversation
…tics `transformToStochastic` returns a `GeneralKineticsStochasticFunction` when a reaction's rate law cannot be reduced to mass-action form (e.g. Hill / Michaelis-Menten kinetics). The existing `instanceof MassActionStochasticFunction` check correctly leaves `maFunc` null in that case, but the next line dereferenced it unconditionally (`maFunc.forwardRate()`), producing an NPE far from the real cause. Particle math mapping requires mass-action shape regardless, so the correct behavior is to throw the same `MappingException` whether `maFunc` is null or has both rates null. Adding `maFunc == null ||` to the guard yields a descriptive error pointing at the offending reaction instead of an NPE. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
danv61
approved these changes
Apr 30, 2026
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.
Summary
ParticleMathMapping.refreshMathDescription: NPE when a reaction's rate law cannot be reduced to mass-action form.transformToStochasticreturns aGeneralKineticsStochasticFunction(sibling ofMassActionStochasticFunction) for kinetics like Hill / Michaelis-Menten. The existinginstanceofcheck correctly leavesmaFuncnull, but the next line dereferenced it unconditionally → NPE far from the real cause.MappingException(which names the offending reaction) whethermaFuncis null or has both rates null.Why now
Identified during triage of a user-support-email log corpus: this NPE is the second-largest cluster of distinct-incident failures (multiple incidents across all sampled builds, multiple distinct user models). The error users currently see is a stack-trace bottoming out at
ParticleMathMapping.java:732rather than a message naming their reaction.Diff
Test plan
mvn compile test-compile -pl vcell-core -ammvn test -pl vcell-core -Dgroups="Fast"— pre-existingVCellDataTest.test_3DPoetry environmental error is unrelated to this Java change🤖 Generated with Claude Code