Skip to content

fix: read numeric meta values without ClassCastException (#57) - #58

Merged
Fivell merged 1 commit into
mainfrom
test/emergency-requirement-meta-numeric-setup-price
Aug 17, 2026
Merged

fix: read numeric meta values without ClassCastException (#57)#58
Fivell merged 1 commit into
mainfrom
test/emergency-requirement-meta-numeric-setup-price

Conversation

@Fivell

@Fivell Fivell commented Aug 17, 2026

Copy link
Copy Markdown
Member

The @Meta fields were declared Map<String, String>, which enforces nothing: jsonapi-converter
deserializes by erased field type, so Jackson stored JSON numbers as Integer and the accessors
threw. Fixtures used strings for both keys, so the suite stayed green while every priced
emergency_requirements response crashed.

MetaMap extends HashMap<String, String> keeps the value type visible to Jackson, which coerces
scalars on parse. Accessors are unchanged and getMeta() stays assignable to Map<String, String>,
so no consumer source change is needed.

Fixtures now carry both wire forms — setup_price as a number and as a string.

213 tests, 0 failures.

Closes #57

@sonarqubecloud

Copy link
Copy Markdown

@sonarqubecloud

Copy link
Copy Markdown

@Fivell
Fivell force-pushed the test/emergency-requirement-meta-numeric-setup-price branch 4 times, most recently from 97d73af to 9499899 Compare August 17, 2026 19:09
@Fivell
Fivell requested a balanced review from Copilot August 17, 2026 19:11
@Fivell
Fivell marked this pull request as ready for review August 17, 2026 19:11
@Fivell Fivell changed the title WIP: reproduce #57 — numeric setup_price in EmergencyRequirement meta fix: read numeric meta values without ClassCastException (#57) Aug 17, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Adds regression coverage and a deserialization fix for numeric setup_price metadata in emergency requirements.

Changes:

  • Introduces MetaMap to 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
Fivell force-pushed the test/emergency-requirement-meta-numeric-setup-price branch 4 times, most recently from 643e4dd to 43c2192 Compare August 17, 2026 19:40
@Fivell
Fivell requested a balanced review from Copilot August 17, 2026 19:42

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated no new comments.

@didww didww deleted a comment from strix-security Bot Aug 17, 2026
@Fivell
Fivell force-pushed the test/emergency-requirement-meta-numeric-setup-price branch 2 times, most recently from 5409806 to 25b3820 Compare August 17, 2026 20:31
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
Fivell force-pushed the test/emergency-requirement-meta-numeric-setup-price branch from 25b3820 to feaad89 Compare August 17, 2026 20:40
@sonarqubecloud

Copy link
Copy Markdown

@Fivell
Fivell merged commit 7687174 into main Aug 17, 2026
5 checks passed
@Fivell
Fivell deleted the test/emergency-requirement-meta-numeric-setup-price branch August 17, 2026 20:42
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)
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.

ClassCastException in getMetaSetupPrice(): meta map is typed Map<String, String> but holds numbers

2 participants