Skip to content

Metadata should have a nicely typed put method #338

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
ydolzhenko opened this issue Mar 20, 2025 · 2 comments
Open

Metadata should have a nicely typed put method #338

ydolzhenko opened this issue Mar 20, 2025 · 2 comments

Comments

@ydolzhenko
Copy link

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.

@ydolzhenko ydolzhenko changed the title Metadata Metadata with numeric fields fails requests in Response API Mar 20, 2025
@IvanLuchkin
Copy link

Image

The SDK does not do automatic conversion.

@TomerAberbach
Copy link
Collaborator

Yeah, this is sort of a bug in the SDK I would say.

It is true that the API only accepts strings, but for most other classes in the SDK we accept nicely typed parameters somehow and then have putAdditionalProperty for undocumented values.

So I think we need to update Metadata to have something like putProperty(String, String). Thanks for flagging :)

@TomerAberbach TomerAberbach changed the title Metadata with numeric fields fails requests in Response API Metadata should have a nicely typed put method Mar 25, 2025
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

No branches or pull requests

3 participants