{"record":{"id":"0ba9455279f21f61","repo":"github/copilot-sdk","slug":"systemmessagesection-value-cannot-be-null","errorCode":null,"errorMessage":"SystemMessageSection value cannot be null.","messagePattern":"SystemMessageSection value cannot be null\\.","errorType":"exception","errorClass":"JsonException","httpStatus":null,"severity":"error","filePath":"dotnet/src/Types.cs","lineNumber":2318,"sourceCode":"    /// <inheritdoc/>\n    public override string ToString() => Value;\n\n    /// <summary>Provides a <see cref=\"JsonConverter{SystemMessageSection}\"/> for serializing <see cref=\"SystemMessageSection\"/> instances.</summary>\n    [EditorBrowsable(EditorBrowsableState.Never)]\n    public sealed class Converter : JsonConverter<SystemMessageSection>\n    {\n        /// <inheritdoc/>\n        public override SystemMessageSection Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)\n        {\n            if (reader.TokenType != JsonTokenType.String)\n            {\n                throw new JsonException(\"Expected string for SystemMessageSection.\");\n            }\n\n            var value = reader.GetString();\n            if (value is null)\n            {\n                throw new JsonException(\"SystemMessageSection value cannot be null.\");\n            }\n\n            return new SystemMessageSection(value);\n        }\n\n        /// <inheritdoc/>\n        public override void Write(Utf8JsonWriter writer, SystemMessageSection value, JsonSerializerOptions options) =>\n            writer.WriteStringValue(value.Value);\n\n        /// <inheritdoc/>\n        public override SystemMessageSection ReadAsPropertyName(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) =>\n            new(reader.GetString()!);\n\n        /// <inheritdoc/>\n        public override void WriteAsPropertyName(Utf8JsonWriter writer, SystemMessageSection value, JsonSerializerOptions options) =>\n            writer.WritePropertyName(value.Value);\n    }\n}","sourceCodeStart":2300,"sourceCodeEnd":2336,"githubUrl":"https://github.com/github/copilot-sdk/blob/cd8cf15dc3f9e762615790aaed0a771a0f392755/dotnet/src/Types.cs#L2300-L2336","documentation":"After confirming a string token, the SystemMessageSection converter calls reader.GetString(); if it returns null the converter throws this JsonException, since a SystemMessageSection must wrap a concrete string value.","triggerScenarios":"reader.GetString() yields null during deserialization of a SystemMessageSection — typically from an unexpected reader state or a malformed document.","commonSituations":"Truncated JSON buffers; manually driven Utf8JsonReader misuse; documents where the string token cannot yield a value.","solutions":["Ensure the JSON is complete and valid before deserializing.","Provide a non-null string for the field.","Use a schema validator on the payload first.","Catch JsonException and wrap it with payload context."],"exampleFix":"// before\n{\"section\": null} // or truncated JSON\n// after\n{\"section\": \"overview\"}","handlingStrategy":"try-catch","validationCode":"using var doc = JsonDocument.Parse(json); // fail early on malformed input\n_ = doc.RootElement.GetProperty(\"section\").GetString() ?? throw new InvalidDataException(\"section missing\");","typeGuard":null,"tryCatchPattern":"try { sm = JsonSerializer.Deserialize<SystemMessage>(json); }\ncatch (JsonException ex) { throw new InvalidDataException(\"malformed SystemMessageSection\", ex); }","preventionTips":["Never emit null for non-nullable section fields","Parse full documents before deserializing","Schema-validate payloads","Add round-trip serialization tests"],"tags":["json","deserialization","dotnet","null"],"backgroundTag":"json-unmarshal-failed","analyzedSha":"cd8cf15dc3f9e762615790aaed0a771a0f392755","analyzedAt":"2026-09-09T18:32:31.973Z","contentChangedAt":"2026-09-09T18:32:31.973Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}