{"record":{"id":"df384be8cc1cf7de","repo":"microsoft/aspire","slug":"unexpected-end-of-json-while-reading-property-value","errorCode":null,"errorMessage":"Unexpected end of JSON while reading property value.","messagePattern":"Unexpected end of JSON while reading property value\\.","errorType":"exception","errorClass":"JsonException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Dashboard/Model/GenAI/GenAIMessageParsingHelper.cs","lineNumber":128,"sourceCode":"            var propertyName = reader.GetString();\n\n            switch (propertyName)\n            {\n                case \"role\":\n                    if (!reader.Read())\n                    {\n                        throw new JsonException(\"Unexpected end of JSON while reading role value.\");\n                    }\n                    role = reader.GetString();\n                    break;\n                case \"parts\":\n                    // DeserializeArrayIncrementally reads the StartArray token itself.\n                    (parts, partsTruncated) = DeserializeArrayIncrementally<MessagePart>(ref reader, ReadMessagePart);\n                    break;\n                default:\n                    if (!reader.Read())\n                    {\n                        throw new JsonException(\"Unexpected end of JSON while reading property value.\");\n                    }\n\n                    if (!reader.TrySkip())\n                    {\n                        throw new JsonException(\"Unexpected end of JSON while skipping property value.\");\n                    }\n                    break;\n            }\n        }\n\n        return (role ?? string.Empty, parts ?? [], partsTruncated);\n    }\n\n    /// <summary>\n    /// If the node is a JSON string that parses to a JSON object or array, return the parsed node instead.\n    /// </summary>\n    internal static JsonNode? TryParseStringJsonNode(JsonNode? node)\n    {","sourceCodeStart":110,"sourceCodeEnd":146,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Dashboard/Model/GenAI/GenAIMessageParsingHelper.cs#L110-L146","documentation":"ReadChatMessage hits a property name it does not recognize (default case) and calls reader.Read() to move to the property's value. If the reader has no more data the JSON is truncated inside the object, so JsonException is thrown. The parser only knows how to skip unknown values, not reconstruct them.","triggerScenarios":"A GenAI message object containing an unknown property (any name other than \"role\" or \"parts\") whose value token is missing because the JSON ended right after the property name, e.g. {\"role\":\"user\",\"metadata\"}.","commonSituations":"Newer emitter versions add extra message fields that older dashboard parsers skip — truncation at exactly that point surfaces this; clipped OTLP log bodies from exporter size limits.","solutions":["Ensure the full message JSON is present — re-export or re-read the telemetry without truncation","Validate the payload with JsonDocument.Parse first to catch malformed bodies before incremental parsing","If a vendor adds fields, update the Aspire Dashboard so known properties are parsed rather than relying on the skip path","Catch JsonException around message parsing and fall back to showing the raw content"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"using var doc = JsonDocument.Parse(json);\nforeach (var prop in doc.RootElement.EnumerateObject())\n    if (prop.Name is not (\"role\" or \"parts\") && prop.Value.ValueKind == JsonValueKind.Undefined)\n        throw new FormatException($\"Property '{prop.Name}' has no value — payload truncated.\");","typeGuard":null,"tryCatchPattern":"try { ParseChatMessage(json); }\ncatch (JsonException ex)\n{\n    logger.LogWarning(ex, \"GenAI message could not be parsed; unknown property may be truncated.\");\n}","preventionTips":["Keep exporter body length limits large enough for full nested structures","Update dashboard parsers when emitters add new message fields","Pre-validate payloads with JsonDocument.Parse to localize truncation"],"tags":["json","truncated-input","genai","parsing"],"backgroundTag":"json-parse-error","analyzedSha":"25830f84bd145686607ad00c057b3f84e2e51d43","analyzedAt":"2026-09-16T11:10:06.193Z","contentChangedAt":"2026-09-16T11:10:06.193Z","schemaVersion":2},"datasetVersion":"2026-09-21T04:17:39.646Z"}