GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix: accept quoted numeric strings in OrganizationCostsResult.Amount.value() (#769) by kuntal1461 · Pull Request #771 · openai/openai-java

Conversation

@kuntal1461

@kuntal1461 kuntal1461 commented Jul 12, 2026

Copy link
Copy Markdown

Summary

  • Fixes GitHub issue OpenAI Java lib 4.41.0 throws OpenAIInvalidDataException in OrganizationCostsResult when parsing amount values #769: OrganizationCostsResult.Amount.value() threw OpenAIInvalidDataException when the live API returned amount.value as a quoted numeric string (e.g. "0E-6176") despite the OpenAPI spec declaring type: number
  • Root cause: Jackson's CoercionAction.Fail for String→Float caused tryDeserialize to return null for quoted numeric strings, leaving a JsonString in the JsonField which getOptional() rejected as invalid
  • Fix adds a BigDecimal fallback in Amount.value(): if asKnown() is absent and the backing field is a JsonString, parse via BigDecimal → Double with an isFinite() guard to reject overflow

Test plan

  • quoted 0E-6176 zero-cost string returns 0.0 — primary bug reproduction verified locally
  • Valid JSON number path unchanged
  • Non-numeric strings still throw OpenAIInvalidDataException
  • Overflow ("1e309") rejected by isFinite() guard
  • validate() benefits automatically (calls value() internally)

Authored-By: Kuntal maity [email protected]

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@kuntal1461
fix: accept quoted numeric strings in OrganizationCostsResult.Amount.…
cbfb2e7
…value() (openai#769)

The live API returns `OrganizationCostsResult.Amount.value` as a quoted
numeric string (e.g. "0E-6176") despite the OpenAPI spec declaring
`type: number`. Jackson's CoercionAction.Fail for String→Float causes
tryDeserialize to return null, leaving a JsonString in the JsonField
which getOptional() then rejects as invalid data.

Fix adds a BigDecimal fallback in Amount.value(): if asKnown() is absent
and the backing field is a JsonString, parse via BigDecimal → Double with
an isFinite() guard to reject overflow.

Authored-By: Kuntal maity <[email protected]>
@kuntal1461
kuntal1461 requested a review from a team as a code owner July 12, 2026 19:58
@jlangch jlangch mentioned this pull request Aug 16, 2026
OpenAI Java lib 4.41.0 throws OpenAIInvalidDataException in OrganizationCostsResult when parsing amount values #769
Closed
@dpiet-oai ChatGPT Codex Connector

dpiet-oai commented Sep 20, 2026

Copy link
Copy Markdown
Contributor

Thanks for the contribution! The underlying issue in #769 was resolved server-side: the Costs API now returns amount.value as a JSON number, matching its documented contract. The original reporter also observed the corrected behavior.

Closing this PR because the client-side string-parsing workaround is no longer needed for this bug. We appreciate your work on the fix.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@dpiet-oai dpiet-oai closed this Sep 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@kuntal1461 @dpiet-oai
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.