NASA-AMMOS / NASA-AMMOS/plandev

NumberFormatException when serializing infinite floating point resource

Open
#1,050 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
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:

  1. Providing a better error message
  2. Providing that error message sooner
  3. Supporting -Infinity, Infinity, and NaN in Aerie resources by encoding them as strings
  4. Providing guardrails in the merlin framework to protect against these errors

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.