Skip to content

Conversation

@mpritham
Copy link
Contributor

@mpritham mpritham commented Oct 7, 2025

Before this PR

Aliases of doubles are valid keys in maps. Keys in maps are serialized as strings. Aliases of doubles can only be deserialized from NaN, Infinity, and -Infinity. We should support deserialization of other valid double values.

After this PR

==COMMIT_MSG==
Support deserialization of double aliases from strings
==COMMIT_MSG==

Possible downsides?

@changelog-app
Copy link

changelog-app bot commented Oct 7, 2025

Generate changelog in changelog/@unreleased

Type (Select exactly one)

  • Feature (Adding new functionality)
  • Improvement (Improving existing functionality)
  • Fix (Fixing an issue with existing functionality)
  • Break (Creating a new major version by breaking public APIs)
  • Deprecation (Removing functionality in a non-breaking way)
  • Migration (Automatically moving data/functionality to a new system)

Description

Support deserialization of double aliases from strings

Check the box to generate changelog(s)

  • Generate changelog entry

default:
throw new IllegalArgumentException("Cannot deserialize string into double: " + value);
try {
double doubleValue = Double.parseDouble(value);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just call Double.parseDouble? Because we don't want to accept things like hexadecimals and 1e10 (but we can accept 1.0E10 because that's a properly formatted double).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add this as a comment on the codegen code? I could certainly see this be asked in a couple of years and someone changing this because they fail to find your PR comment

@changelog-app
Copy link

changelog-app bot commented Oct 7, 2025

Successfully generated changelog entry!

What happened?

Your changelog entries have been stored in the database as part of our migration to ChangelogV3.

Need to regenerate?

Simply interact with the changelog bot comment again to regenerate these entries.

default:
throw new IllegalArgumentException("Cannot deserialize string into double: " + value);
try {
double doubleValue = Double.parseDouble(value);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add this as a comment on the codegen code? I could certainly see this be asked in a couple of years and someone changing this because they fail to find your PR comment

Comment on lines 79 to -80
default:
throw new IllegalArgumentException("Cannot deserialize string into double: " + value);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this specific to map keys? How are we deserializing non-map-key double aliases if not through this code? (I'm asking specifically because I'm curious about the perf cost of this change - it might not matter if it's for double alias map keys, but maybe more so if that's for all double alias deserializations?)

bearertokens: map<BearerTokenAliasExample, ManyFieldExample>
integers: map<IntegerAliasExample, ManyFieldExample>
# doubles: map<DoubleAliasExample, ManyFieldExample> # typescript freaks out with the 'NaN'
doubles: map<DoubleAliasExample, ManyFieldExample> # typescript freaks out with the 'NaN'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I would probably just remove the typescript comment too, as I'm unclear what value it provides in the conjure-java repo

Suggested change
doubles: map<DoubleAliasExample, ManyFieldExample> # typescript freaks out with the 'NaN'
doubles: map<DoubleAliasExample, ManyFieldExample>

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.

3 participants