fix: NatsMessageRpcResponder SerializePayload must use CamelCase JSON options

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 <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
This commit is contained in:
dingo
2026-03-01 22:28:33 -05:00
co-authored by Claude Happy
parent fa5beb104c
commit cec6773a12
@@ -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) =>