fix: correct Prompt serialization, Test.metadata alias, and multi-turn NPE#5
Merged
Conversation
Fixes #3 and two related bugs discovered during the audit. - Prompt: add `expectedResponse` and `languageCode` as direct top-level fields (JSON: `expected_response`, `language_code`) so they are sent to the backend as siblings of `content` rather than nested under `metadata`. Previously the backend silently dropped them, leaving no expected response on the platform. - Prompt: remove `role` field — it was never part of the backend API or Python SDK. - Prompt: annotate with `@JsonInclude(NON_NULL)` so unset fields are omitted. - Test: add `@JsonAlias("test_metadata")` on `metadata` so it deserialises from the backend's GET response key (`test_metadata`) that differs from the POST key (`metadata`). Previously `test.metadata()` was always null after a round-trip. - MultiTurnSynthesizer: null-guard `min_turns`/`max_turns` before casting to int. An LLM can omit these fields even when the schema marks them required, causing a NullPointerException. Values are now treated as optional, matching the Python SDK. Tests added: - BaseSynthesizerTest: null-turns NPE regression + numeric-turns positive case - ClientWiremockTest: WireMock guard asserting `expected_response`/`language_code` appear at `$.tests[0].prompt.*` in outbound POST /test_sets/bulk requests - EntityTest: JSON-tree regression guard for top-level Prompt fields; alias tests for both `metadata` and `test_metadata` deserialization paths - PromptRoundTripIntegrationTest: live backend round-trip for `expected_response` - TestSetRoundTripIntegrationTest: live backend round-trips for multi-turn `test_configuration` fields and `test_metadata` → `metadata` alias
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Fixes #3 and two additional bugs discovered during the audit.
Prompt.expectedResponse/languageCodenow serialize at the top level — previously they were nested underprompt.metadata, causing the backend to silently drop them. Generated tests had no expected response on the platform.Prompt.roleremoved — was never part of the backend API or Python SDK.Test.metadatadeserializes from the backend'stest_metadatakey — the backend renamesmetadata→test_metadatain GET responses to avoid a SQLAlchemy naming conflict.@JsonAlias("test_metadata")is now added sotest.metadata()is no longer alwaysnullafter a round-trip.MultiTurnSynthesizerno longer NPEs on missingmin_turns/max_turns— an LLM can omit these fields even when the schema marks them required. Values are now treated as optional, matching the Python SDK.Test plan
BaseSynthesizerTest— null-turns NPE regression + numeric-turns positive case +expected_response/language_codetop-level serialization (issue expected_response nested under prompt.metadata instead of directly on prompt, causing test evaluation to fail #3)EntityTest— JSON-tree regression guard for top-levelPromptfields; alias unit tests for bothmetadataandtest_metadatadeserialization paths;NON_NULLserialization checkClientWiremockTest— WireMock guard assertingexpected_response/language_codeappear at$.tests[0].prompt.*in outboundPOST /test_sets/bulk(not undermetadata)PromptRoundTripIntegrationTest— live backend round-trip verifyingexpected_responsesurvivesPOST /test_sets/bulk→GET /test_sets/{id}/tests(the exact scenario from issue expected_response nested under prompt.metadata instead of directly on prompt, causing test evaluation to fail #3)TestSetRoundTripIntegrationTest— live backend round-trips for multi-turntest_configurationfields andtest_metadata→metadataaliasAll 55 unit tests + 5 live-backend integration tests pass.