You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
JsonSerializationProvider.Deserialize(ReadOnlySpan<byte>) returns null for UTF-8 JSON that starts with a BOM (the YAML provider accepts it) #76
Essentials.SerializationProviders.Json/JsonSerializationProvider.cs:68Deserialize<T>(ReadOnlySpan<byte> data) passes the bytes straight to JsonSerializer.Deserialize<T>(data, options). System.Text.Json's UTF-8 span overload does not skip a byte-order mark, so input starting with EF BB BF throws JsonException. The provider catches that and returns default.
bytes = EF BB BF + {"A":1}
Json provider Deserialize<Dictionary<string,int>>(bytes) -> null
Yaml provider Deserialize<Dictionary<string,int>>(bytes) -> ok
Why it matters
File.ReadAllBytes on a file saved by Notepad, Visual Studio or PowerShell 5 (Out-File -Encoding utf8) produces exactly this input. The caller gets null, as if the data were empty or corrupt. Because failure is swallowed, nothing points at the BOM. The YAML provider handles the same bytes, so switching providers behind ISerializationProvider changes the result. The text-based paths (for example FileSystem/Temp persistence via ReadAllTextAsync) are unaffected because the reader strips the BOM.
Apply the same fix to any other byte-based deserialize path in the JSON provider (and check the NewtonsoftJson/Toml providers' byte overloads for parity).
Acceptance: a test that BOM-prefixed UTF-8 JSON deserializes to the same value as the unprefixed bytes, for the JSON provider and each other serialization provider's byte overload.
Priority: Medium. File.ReadAllBytes on a file saved by Notepad, Visual Studio or PowerShell 5 produces exactly this input. The caller gets null with no error, and the JSON and YAML providers disagree on the same bytes, which breaks the ISerializationProvider swap promise.
Area / suggested assignment:Essentials.SerializationProviders.Json, with a parity check on the Newtonsoft and TOML byte overloads. The acceptance test belongs in the cross-provider contract tests.
Activity
matt-edmondson commentedon Sep 30, 2026
Triage
File.ReadAllByteson a file saved by Notepad, Visual Studio or PowerShell 5 produces exactly this input. The caller getsnullwith no error, and the JSON and YAML providers disagree on the same bytes, which breaks theISerializationProviderswap promise.Essentials.SerializationProviders.Json, with a parity check on the Newtonsoft and TOML byte overloads. The acceptance test belongs in the cross-provider contract tests.TrySerializecloses the caller's writer) and TOML provider loses multi-word properties, lists and nested objects on a round trip, and throws MissingMethodException for records #69 (TOML round-trip losses). Both are serialization-provider parity defects, but neither is this one.Generated by Claude Code