DevUI: Serialize workflow input as string to maintain conformance with OpenAI Responses format (#2021)

Co-authored-by: Victor Dibia <chuvidi2003@gmail.com>
This commit is contained in:
Reuben Bond
2025-11-08 03:25:08 +00:00
committed by GitHub
co-authored by Victor Dibia
parent 1aaf37dab8
commit 4201b9a122
5 changed files with 78 additions and 39 deletions
@@ -182,7 +182,9 @@ internal sealed class ResponseInputJsonConverter : JsonConverter<ResponseInput>
return messages is not null ? ResponseInput.FromMessages(messages) : null;
}
throw new JsonException($"Unexpected token type for ResponseInput: {reader.TokenType}");
throw new JsonException(
"ResponseInput must be either a string or an array of messages. " +
$"Objects are not supported. Received token type: {reader.TokenType}");
}
/// <inheritdoc/>
@@ -344,6 +344,20 @@ public sealed class OpenAIResponsesSerializationTests : ConformanceTestBase
Assert.NotNull(request.Input);
}
[Fact]
public void Deserialize_InvalidInputObject_ThrowsHelpfulException()
{
// Arrange
const string Json = "{\"model\":\"gpt-4o-mini\",\"input\":{\"input\":\"testing!\"},\"stream\":true}";
// Act & Assert
var exception = Assert.Throws<JsonException>(() =>
JsonSerializer.Deserialize(Json, OpenAIHostingJsonContext.Default.CreateResponse));
Assert.Contains("ResponseInput must be either a string or an array of messages", exception.Message);
Assert.Contains("Objects are not supported", exception.Message);
}
[Fact]
public void Deserialize_AllRequests_CanBeDeserialized()
{