Skip to content

[Android/Quest3] Failed to parse Response because JsonSerialization: Cannot deserialize readonly or fixed size dictionary #402

@dudziakl

Description

@dudziakl

Bug Report

I have copied SubmitChat method from ResponsesBehaviour.cs. Everything works fine in Unity Playmode on PC but when I build the app for the Quest 3 (Android) I have an exception in this EventHandler

async Task StreamEventHandler(string eventName, IServerSentEvent sseEvent)

Here is the sample from the logcat:

Failed to parse Response -> {
"id": "resp_68b1d5705eb081978ec5d182e7c2acfb0e006c82ec3a78a3",
"object": "response",
"created_at": 1756484976,
"status": "in_progress",
"background": false,
"error": null,
"incomplete_details": null,
"instructions": null,
"max_output_tokens": null,
"max_tool_calls": null,
"model": "gpt-4o-mini-2024-07-18",
"output": [],
"parallel_tool_calls": true,
"previous_response_id": null,
"prompt_cache_key": null,
"reasoning": {
"effort": null,
"summary": null
},
"safety_identifier": null,
"service_tier": "auto",
"store": true,
"temperature": 1.0,
"text": {
"format": {
"type": "text"
},
"verbosity": "medium"
},
"tool_choice": "none",
"tools": [],
"top_logprobs": 0,
"top_p": 1.0,
"truncation": "auto",
"usage": null,
"user": null,
"metadata": {}
}
Newtonsoft.Json.JsonSerializationException: Cannot deserialize readonly or fixed size dictionary: System.Collections.Generic.IReadOnlyDictionary`2[System.String,System.String]. Path 'response.metadata', line 1, position 731.
at App.FeedbackBehaviour.g__StreamEventHandler|9_0 (System.String eventName, Utilities.WebRequestRest.Interfaces.IServerSentEvent sseEvent) [0x00000] in <00000000000000000000000000000000>:0
at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[TStateMachine] (TStateMachine& stateMachine) [0x00000] in <00000000000000000000000000000000>:0
at App.FeedbackBehaviour.g__StreamEventHandler|9_0 (System.String eventName, Utilities.WebRequestRest.Interfaces.IServerSentEvent sseEvent) [0x00000] in <00000000000000000000000000000000>:0
at OpenAI.Responses.ResponsesEndpoint+<>c__DisplayClass7_0.b__0 (Utilities.WebRequestRest.Response sseResponse, Utilities.WebRequestRest.ServerSentEvent ssEvent) [0x00000] in <0

This issue looks very similar to #147 but it affects the Android build.

Response class uses IReadOnlyDictionary<string, string> so this might be the issue

[JsonProperty("metadata")] IReadOnlyDictionary<string, string> metadata = null,

I'm using Unity 6 (6000.0.038f)

The issue was mentioned in Unity forum without fix or workaround :(
https://discussions.unity.com/t/cannot-deserialize-dictionaries-anymore-on-android-builds-after-unity-upgrade/861980

Real-time session works fine. I didn't check the Assistant or Chat API yet.

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions