When using nullable collections in the serializable data classes fro Structured output OpenAIs schema validation fails with 400 response:
Error from client: OpenAILLMClient
Status code: 400
Error body:
{
"error": {
"message": "Invalid schema for response_format 'MyClass': schema must be a JSON Schema of 'type: \"object\"', got 'type: \"None\"'.",
"type": "invalid_request_error",
"param": "response_format",
"code": null
}
}
Nullable list handling for List?: processList(...).asNullableType(...) produces {"type": ["array", "null"], "items": {...}}. Some OpenAI strict validators
reject the array form and want either anyOf: [array, null] or a top-level union elsewhere — pick wrong shape and the validator can't classify the type.
Reproducible with Dan Balla (@serializable) data class with one String field and one List? = null field and structured completion with any GPT 5 family model.
I am happy to contribute and can open a MR in the next days unless someone else already filed this.
When using nullable collections in the serializable data classes fro Structured output OpenAIs schema validation fails with 400 response:
Nullable list handling for List?: processList(...).asNullableType(...) produces {"type": ["array", "null"], "items": {...}}. Some OpenAI strict validators
reject the array form and want either anyOf: [array, null] or a top-level union elsewhere — pick wrong shape and the validator can't classify the type.
Reproducible with Dan Balla (@serializable) data class with one String field and one List? = null field and structured completion with any GPT 5 family model.
I am happy to contribute and can open a MR in the next days unless someone else already filed this.