From cec6773a1262bb7cd25b9aaa7620aaee22764e75 Mon Sep 17 00:00:00 2001 From: dingo Date: Sun, 1 Mar 2026 22:28:33 -0500 Subject: [PATCH] fix: NatsMessageRpcResponder SerializePayload must use CamelCase JSON options MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit SerializePayload was using default JsonSerializerOptions, so record properties like GetStarterDecksResponse.Decks were serialized as "Decks" (PascalCase). That JsonElement travels through the NATS reply back to the gateway, which forwards it verbatim. The client reads p.get("decks", []) and finds nothing → "No starter decks available." Fix: use the same PropertyNamingPolicy=CamelCase that SystemTextJsonSerializer uses, so all payload field names arrive at the client in camelCase. Generated with [Claude Code](https://claude.ai/code) via [Happy](https://happy.engineering) Co-Authored-By: Claude Co-Authored-By: Happy --- .../src/SOR.Networking.Nats/NatsMessageRpcResponder.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Server/src/SOR.Networking.Nats/NatsMessageRpcResponder.cs b/Server/src/SOR.Networking.Nats/NatsMessageRpcResponder.cs index 0328313..f33b5dd 100644 --- a/Server/src/SOR.Networking.Nats/NatsMessageRpcResponder.cs +++ b/Server/src/SOR.Networking.Nats/NatsMessageRpcResponder.cs @@ -219,12 +219,20 @@ public sealed class NatsMessageRpcResponder : IHostedService } } + // Must match SystemTextJsonSerializer.Options so that payload property names + // arrive at the client in camelCase (e.g. "decks", not "Decks"). + private static readonly JsonSerializerOptions _payloadOptions = new() + { + PropertyNamingPolicy = JsonNamingPolicy.CamelCase, + WriteIndented = false, + }; + private static JsonElement? SerializePayload(object? payload) { if (payload is null) return null; - return JsonSerializer.SerializeToElement(payload, payload.GetType()); + return JsonSerializer.SerializeToElement(payload, payload.GetType(), _payloadOptions); } private static string GetRpcSubject(string messageType) =>