openai / openai/openai-java

Metadata should have a nicely typed `put` method

Open
#338 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement sdk
Dominant language
Kotlin
Stars
1.5k
Forks
264
Avg merge
9h 46m
Merged PRs (30d)
96

Description

metadata setter of ResponseCreateParams.builder()accepts Metadata object, which, in turn may contain ```
numeric fields:

        val metadata = Metadata.builder()
            .putAdditionalProperty("someNumericId", JsonNumber.of(123))
            .build();

Response with such metadata instance fails though:

ResponseCreateParams.builder().metadata(metadata).build()....

showing error:

com.openai.errors.BadRequestException: 400: OpenAIError{additionalProperties={error={message=Invalid type for 'metadata.someNumericId': expected a string, but got an integer instead., type=invalid_request_error, param=metadata.someNumericId, code=invalid_type}}}

String as a value works fine though.

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 the Metadata.builder() and ResponseCreateParams.builder().metadata(metadata) entry points shown in the report, then trace how additional metadata values are serialized. Confirm the expected metadata value types and reproduce the numeric-value failure; done means numeric metadata is accepted consistently with the API's documented behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
kotlin
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.