Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

Deserializing ResponseInputItem results in unknown state

Cerrado
#584 2 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
35/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Estancado
Stack tecnológico
java, kotlin
Área
api

Línea de trabajo

Comienza con la ruta de deserialización de ResponseInputItem.Message y compárala con la ruta de ResponseOutputMessage utilizando la reproducción proporcionada testSerializeInputItem. Confirma que los valores serializados y deserializados de ResponseInputItem.Message se comparan como iguales sin convertirse en unknown; la prueba de output-item existente proporciona un caso de comparación funcional.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

bug spec

Hey there! 👋

I'm working with the OpenAI Java SDK for a couple of days now and really like it. The general design of the library is fantastic and I'm having quite a lot fun working with it. Thanks! 👍

I stumbled upon an issue which I think is a bug. Let me first clarify about my goals: I'm using the Responses API part of the library to implement Chat-Bot like conversations. My requirement is to use ResponseCreateParams.builder().store(false) and instead serialize conversation state locally by myself.

Here's an example of what I do:

val jsonMapper = jsonMapper()
val inputItems: List<ResponseInputItem> = ...
val jsonData = jsonMapper.writeValueAsString(inputItems)
// store jsonData locally

// later:
val deserializedInputItems = jsonMapper.readValue(nativeData, object : TypeReference<MutableList<ResponseInputItem>>() {})
// attach new user message and continue conversation

This works pretty well. However I've noticed the following behavior:

When a ResponseInputItem from a ResponseInputItem.Message gets serialized and deserialized again, it's in an unknown state. The message field is null but the _json() field still holds the correct structured data from the original message.

Here's are a Kotlin Test to demonstrate the behavior:

❌ This test fails with v3.0.3

@Test
fun testSerializeInputItem() {
    // given
    val message = ResponseInputItem.Message.builder()
        .role(ResponseInputItem.Message.Role.USER)
        .addInputTextContent("Test")
        .build()
    val inputItem1 = ResponseInputItem.ofMessage(message)

    // when
    val jsonMapper = jsonMapper()
    val inputItemJson = jsonMapper.writeValueAsString(inputItem1)
    val inputItem2 = jsonMapper.readValue(inputItemJson, ResponseInputItem::class.java)

    // then
    Assertions.assertEquals(inputItem1, inputItem2)
}

Test fails:

Expected :ResponseInputItem{message=Message{content=[ResponseInputContent{inputText=ResponseInputText{text=Test, type=input_text, additionalProperties={}}}], role=user, status=, type=, additionalProperties={}}}
Actual   :ResponseInputItem{_unknown={content=[{text=Test, type=input_text}], role=user}}

I couldn't reproduce this issue with other types of ResponseInputItems, e.g. for ResponseOutputMessage the test succeeds:

🟢 This test succeeds with v3.0.3

@Test
fun testSerializeOutputItem() {
    val message = ResponseOutputMessage.builder()
        .id("my_id")
        .status(ResponseOutputMessage.Status.COMPLETED)
        .addContent(
            ResponseOutputText.builder()
                .text("Test")
                .annotations(emptyList())
                .build()
        )
        .build()
    val inputItem1 = ResponseInputItem.ofResponseOutputMessage(message)

    val jsonMapper = jsonMapper()
    val inputItemJson = jsonMapper.writeValueAsString(inputItem1)

    val inputItem2 = jsonMapper.readValue(inputItemJson, ResponseInputItem::class.java)
    Assertions.assertEquals(inputItem1, inputItem2)
}

Could you please clarify if this a bug? Or am I doing something wrong / unintended here?

Lenguaje dominante
Kotlin
Estrellas
1.5k
Forks
266
Merge medio
10 h 11 min
PR fusionados (30 d)
141

Preparar el entorno

Abrir en Codespaces

Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de openai/openai-java

Todos los issues de openai/openai-java

Issues similares

Más issues de Kotlin

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.