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:
@@ -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) =>
|
||||
|
||||
Reference in New Issue
Block a user