Describe the bug
Paramore.Brighter.JsonConverters.JsonSerialisationOptions.Options sets PropertyNamingPolicy = JsonNamingPolicy.CamelCase. DictionaryStringObjectJsonConverter applies that policy to dictionary keys as well as property names.
As a result, MessageHeader.Bag["SessionId"] is serialised as "sessionId". On the consume side, the ASB publisher does a case-sensitive Bag.TryGetValue("SessionId", out _) to decide whether to set ServiceBusMessage.SessionId. The lookup misses, the message is sent without a session, and the ASB broker silently drops it when the destination subscription has session-required = true.
Bag keys are arbitrary string identifiers, not C# property names — applying a property naming policy to them is semantically wrong, and the failure mode is fully silent (no exception, no log line, the message just never arrives).
To Reproduce
- Configure a session-required ASB subscription.
- Send a Brighter message whose
MessageHeader.Bag["SessionId"] is set.
- Round-trip the message through Brighter's STJ serialisation (e.g. via the scheduler envelope path, or any path using
JsonSerialisationOptions.Options).
- Observe the bag at the publisher: the key is now
"sessionId".
- Publisher's
Bag.TryGetValue("SessionId", ...) misses → session-less message → silent drop.
Suggested fix
Set DictionaryKeyPolicy = null on JsonSerialisationOptions.Options (and any sibling options contributing to the envelope serialiser). Bag keys are user-defined identifiers and must round-trip verbatim.
(Alternative — case-insensitive lookup at fire time — papers over symptoms; the root issue is the bag's keys being mutated by a naming policy.)
Further technical details
- Brighter version: 10.4.1
dotnet --info:
.NET SDK 10.0.108 (commit 94ea82652c, MSBuild 18.0.11+94ea82652)
Host 10.0.8 (x64)
RID: win-x64
- OS: Windows 11 (build 10.0.26200)
Describe the bug
Paramore.Brighter.JsonConverters.JsonSerialisationOptions.OptionssetsPropertyNamingPolicy = JsonNamingPolicy.CamelCase.DictionaryStringObjectJsonConverterapplies that policy to dictionary keys as well as property names.As a result,
MessageHeader.Bag["SessionId"]is serialised as"sessionId". On the consume side, the ASB publisher does a case-sensitiveBag.TryGetValue("SessionId", out _)to decide whether to setServiceBusMessage.SessionId. The lookup misses, the message is sent without a session, and the ASB broker silently drops it when the destination subscription has session-required = true.Bag keys are arbitrary string identifiers, not C# property names — applying a property naming policy to them is semantically wrong, and the failure mode is fully silent (no exception, no log line, the message just never arrives).
To Reproduce
MessageHeader.Bag["SessionId"]is set.JsonSerialisationOptions.Options)."sessionId".Bag.TryGetValue("SessionId", ...)misses → session-less message → silent drop.Suggested fix
Set
DictionaryKeyPolicy = nullonJsonSerialisationOptions.Options(and any sibling options contributing to the envelope serialiser). Bag keys are user-defined identifiers and must round-trip verbatim.(Alternative — case-insensitive lookup at fire time — papers over symptoms; the root issue is the bag's keys being mutated by a naming policy.)
Further technical details
dotnet --info: