NASA-AMMOS / NASA-AMMOS/plandev
NumberFormatException when serializing infinite floating point resource
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 128
- Forks
- 33
- Avg merge
- 1d 17h
- Merged PRs (30d)
- 12
Description
Java floating point numbers may take on the values -Infinity, Infinity, and NaN. These three values are not serializable to the JSON number type, and result in variants of the following exception:
java.lang.NumberFormatException: Character I is neither a decimal digit number, decimal point, nor "e" notation exponential mark.
at java.base/java.math.BigDecimal.<init>(Unknown Source)
at java.base/java.math.BigDecimal.<init>(Unknown Source)
at java.base/java.math.BigDecimal.<init>(Unknown Source)
at java.base/java.math.BigDecimal.valueOf(Unknown Source)
at gov.nasa.jpl.aerie.merlin.protocol.types.SerializedValue.of(SerializedValue.java:143)
at gov.nasa.jpl.aerie.merlin.framework.Registrar$2$1.serialize(Registrar.java:88)
at gov.nasa.jpl.aerie.merlin.framework.Registrar$2$1.serialize(Registrar.java:76)
at gov.nasa.jpl.aerie.merlin.driver.engine.SimulationEngine.extractRealDynamics(SimulationEngine.java:657)
at gov.nasa.jpl.aerie.merlin.driver.engine.SimulationEngine.serializeProfile(SimulationEngine.java:649)
at gov.nasa.jpl.aerie.merlin.driver.engine.SimulationEngine.computeResults(SimulationEngine.java:469)
at gov.nasa.jpl.aerie.merlin.driver.SimulationDriver.simulate(SimulationDriver.java:107)
at gov.nasa.jpl.aerie.merlin.server.services.LocalMissionModelService.runSimulation(LocalMissionModelService.java:230)
at gov.nasa.jpl.aerie.merlin.server.services.SynchronousSimulationAgent.simulate(SynchronousSimulationAgent.java:76)
at gov.nasa.jpl.aerie.merlin.worker.MerlinWorkerAppDriver.main(MerlinWorkerAppDriver.java:81)
This exception occurs at the end of simulation when serializing values.
The user experience here is sub-optimal, since the feedback is given only at the end of simulation, and there is no indication of what a user should to do resolve this. The purpose of this ticket is to start a discussion and try to arrive at a better user experience, by one or more of the following:
- Providing a better error message
- Providing that error message sooner
- Supporting
-Infinity,Infinity, andNaNin Aerie resources by encoding them as strings - Providing guardrails in the merlin framework to protect against these errors
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at SerializedValue.java, especially SerializedValue.of, then trace the serialization path through Registrar.java and SimulationEngine.java using the stack trace. Review the proposed options for handling -Infinity, Infinity, and NaN; done requires an agreed user-facing behavior and an implementation scope, which the issue does not yet specify.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- backend-api-design
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100