Skip to content

Add typed metadata property builder - #964

Open
YuqiGuo105 wants to merge 1 commit into
openai:mainfrom
YuqiGuo105:fix/issue-338-typed-metadata
Open

Add typed metadata property builder#964
YuqiGuo105 wants to merge 1 commit into
openai:mainfrom
YuqiGuo105:fix/issue-338-typed-metadata

Conversation

@YuqiGuo105

Copy link
Copy Markdown

Summary

  • add a typed Metadata.Builder.putProperty(String, String) helper for Responses
  • expose the same helper for the Beta Responses API
  • preserve putAdditionalProperty(String, JsonValue) as the escape hatch for undocumented values
  • add regression tests that verify string values are stored as JSON strings

Motivation

The API only accepts string values for metadata, but the existing builder exposes only the raw JsonValue method. This allows values such as JSON numbers to compile and fail later with a 400 response. The typed helper provides a straightforward, API-aligned path while keeping the existing low-level method backward compatible.

Testing

  • targeted stable and Beta ResponseCreateParamsTest tests
  • :openai-java-core:lintKotlin
  • full offline build with mock-server-dependent tests skipped
  • Castiron custom-code budget check (1886 / 2000)

Closes #338

@YuqiGuo105
YuqiGuo105 requested a review from a team as a code owner September 2, 2026 18:27
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 2, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-02T18:30:10.986425Z 1790828 PR opened
🔒 Security Review Completed 2026-09-02T18:29:28.640336Z 1790828 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@sylvesterkaczmarek sylvesterkaczmarek 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.

This is a useful API-level narrowing over the raw additional-properties escape hatch. The helper guarantees metadata values are serialized as JSON strings, which matches the service contract and avoids callers accidentally sending numeric JSON for numeric-looking IDs. Mirroring it in both stable and beta response params keeps the two surfaces consistent.

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.

Metadata should have a nicely typed put method

2 participants