fix: read numeric meta values without ClassCastException (#57) - #58
Merged
Merged
Conversation
|
|
Fivell
force-pushed
the
test/emergency-requirement-meta-numeric-setup-price
branch
4 times, most recently
from
August 17, 2026 19:09
97d73af to
9499899
Compare
Fivell
marked this pull request as ready for review
August 17, 2026 19:11
There was a problem hiding this comment.
Pull request overview
Adds regression coverage and a deserialization fix for numeric setup_price metadata in emergency requirements.
Changes:
- Introduces
MetaMapto coerce numeric metadata values to strings. - Applies it to three resource types.
- Updates fixtures and assertions for the production response shape.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
src/test/resources/fixtures/emergency_requirements/show.json |
Uses numeric setup_price. |
src/test/resources/fixtures/emergency_requirements/index.json |
Adds numeric and string price cases. |
src/test/java/com/didww/sdk/resource/EmergencyRequirementTest.java |
Verifies both price representations. |
src/main/java/com/didww/sdk/resource/MetaMap.java |
Adds typed metadata deserialization. |
src/main/java/com/didww/sdk/resource/EmergencyRequirement.java |
Uses MetaMap and updates documentation. |
src/main/java/com/didww/sdk/resource/EmergencyCallingService.java |
Migrates pricing metadata to MetaMap. |
src/main/java/com/didww/sdk/resource/DidHistory.java |
Migrates history metadata to MetaMap. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| */ | ||
| @Meta | ||
| private Map<String, String> meta; | ||
| private MetaMap meta; |
| */ | ||
| @Meta | ||
| private Map<String, String> meta; | ||
| private MetaMap meta; |
|
|
||
| @Meta | ||
| private Map<String, String> meta; | ||
| private MetaMap meta; |
Comment on lines
+16
to
+19
| * <p>Server-provided {@code meta} carries {@code setup_price}, always "0" because services | ||
| * ordered through this API are never charged a setup fee, and {@code monthly_price}. Both are | ||
| * null when the account's emergency plan has no rate for this country and DID group type, in | ||
| * which case the service cannot be ordered. |
Comment on lines
+6
to
+9
| * JSON:API {@code meta} with string values. Do not replace with a {@code Map<String, String>} | ||
| * field: jsonapi-converter deserializes by erased field type, so Jackson would see a raw | ||
| * {@code Map}, store JSON numbers as {@code Integer}, and the accessors would throw | ||
| * {@link ClassCastException}. Only a named class keeps the value type visible to Jackson. |
Fivell
force-pushed
the
test/emergency-requirement-meta-numeric-setup-price
branch
4 times, most recently
from
August 17, 2026 19:40
643e4dd to
43c2192
Compare
Fivell
force-pushed
the
test/emergency-requirement-meta-numeric-setup-price
branch
2 times, most recently
from
August 17, 2026 20:31
5409806 to
25b3820
Compare
The @meta fields were declared Map<String, String>, which enforces nothing: jsonapi-converter deserializes meta by erased field type, so Jackson saw a raw Map and stored JSON numbers as Integer. Every emergency_requirements response carrying a price crashed in getMetaSetupPrice(), while the fixtures used strings for both keys and kept the suite green. MetaMap is a named subclass of HashMap<String, String>, so the value type stays visible to Jackson and scalars are coerced on parse. Accessors are unchanged and getMeta() remains assignable to Map<String, String>. Fixtures now match the wire format, and the parameterized test covers every JSON type setup_price could arrive as, including the string form a server-side fix of the number/string mismatch would produce. Closes #57
Fivell
force-pushed
the
test/emergency-requirement-meta-numeric-setup-price
branch
from
August 17, 2026 20:40
25b3820 to
feaad89
Compare
|
Fivell
added a commit
that referenced
this pull request
Aug 17, 2026
The @meta fields were declared Map<String, String>, which enforces nothing: jsonapi-converter deserializes meta by erased field type, so Jackson saw a raw Map and stored JSON numbers as Integer. Every emergency_requirements response carrying a price crashed in getMetaSetupPrice(), while the fixtures used strings for both keys and kept the suite green. MetaMap is a named subclass of HashMap<String, String>, so the value type stays visible to Jackson and scalars are coerced on parse. Accessors are unchanged and getMeta() remains assignable to Map<String, String>. Fixtures now match the wire format, and the parameterized test covers every JSON type setup_price could arrive as, including the string form a server-side fix of the number/string mismatch would produce. Closes #57 (cherry picked from commit 7687174)
Fivell
added a commit
that referenced
this pull request
Aug 17, 2026
The @meta fields were declared Map<String, String>, which enforces nothing: jsonapi-converter deserializes meta by erased field type, so Jackson saw a raw Map and stored JSON numbers as Integer. Every emergency_requirements response carrying a price crashed in getMetaSetupPrice(), while the fixtures used strings for both keys and kept the suite green. MetaMap is a named subclass of HashMap<String, String>, so the value type stays visible to Jackson and scalars are coerced on parse. Accessors are unchanged and getMeta() remains assignable to Map<String, String>. Fixtures now match the wire format, and the parameterized test covers every JSON type setup_price could arrive as, including the string form a server-side fix of the number/string mismatch would produce. Closes #57 (cherry picked from commit 7687174)
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.



The
@Metafields were declaredMap<String, String>, which enforces nothing: jsonapi-converterdeserializes by erased field type, so Jackson stored JSON numbers as
Integerand the accessorsthrew. Fixtures used strings for both keys, so the suite stayed green while every priced
emergency_requirementsresponse crashed.MetaMap extends HashMap<String, String>keeps the value type visible to Jackson, which coercesscalars on parse. Accessors are unchanged and
getMeta()stays assignable toMap<String, String>,so no consumer source change is needed.
Fixtures now carry both wire forms —
setup_priceas a number and as a string.213 tests, 0 failures.
Closes #57