microsoft/aspire · error · JsonException
Unexpected end of JSON while skipping property value.
Error message
Unexpected end of JSON while skipping property value.
What it means
After reading the value token of an unknown property, ReadChatMessage calls Utf8JsonReader.TrySkip() to bypass nested content. TrySkip returns false when the reader reaches the end of the data before the value's closing token, meaning the JSON is truncated inside a nested object/array, so JsonException is thrown.
Solutions
- Check that the recorded body is complete — compare against the original telemetry payload length
- Increase exporter/dashboard body size limits (OTEL attribute value length limits) so nested content is not cut
- Pre-validate with JsonDocument.Parse to reject truncated payloads with a clearer message
- Wrap the parse call so the entry renders as unparseable instead of breaking the visualizer
Defensive patterns
Strategy: validation
Validate before calling
using var doc = JsonDocument.Parse(json); // Parse fully validates nesting; a truncated nested value throws here first
if (doc.RootElement.ValueKind != JsonValueKind.Object)
throw new FormatException("Chat message must be a complete JSON object."); Type guard
static bool IsWellFormedJsonObject(string json)
{
try { using var d = JsonDocument.Parse(json); return d.RootElement.ValueKind == JsonValueKind.Object; }
catch (JsonException) { return false; }
} Try / catch
try { ParseChatMessage(json); }
catch (JsonException ex) when (ex.Message.Contains("skipping property value"))
{
logger.LogWarning("GenAI message nested value truncated: {Message}", ex.Message);
} Prevention
- Verify exported attribute length limits cover nested arrays/objects end to end
- Never truncate payloads by raw byte slicing — serialize complete structures only
- Run a full JSON parse as a pre-flight gate before reader-based parsing
When it happens
Trigger: An unrecognized property with a nested value (object or array) where the JSON ends before the matching close bracket, e.g. {"role":"user","attachments":[{"type":"file"} — with the closing tokens missing.
Common situations: Telemetry bodies clipped by attribute length limits in the middle of nested structures; partially written log files; copy/paste truncation of payloads during debugging.
Understand the failure class
Background: JSON parse error: "Unexpected token" / "not valid JSON" / "failed to parse" — what JSON parsers are really complaining about — this error's family across 45 libraries.
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- Unexpected end of JSON while reading property value.
- Unexpected end of JSON while reading role value.
- Expected a JSON array.
- Expected property name.
- Expected start of chat message object.
AI-assisted analysis of microsoft/aspire@25830f84bd (2026-09-16).
Data as JSON: /api/errors/d3f3dd791fce0784.
Report an issue: GitHub.
Appendix: source
Thrown at src/Aspire.Dashboard/Model/GenAI/GenAIMessageParsingHelper.cs:133
if (!reader.Read())
{
throw new JsonException("Unexpected end of JSON while reading role value.");
}
role = reader.GetString();
break;
case "parts":
// DeserializeArrayIncrementally reads the StartArray token itself.
(parts, partsTruncated) = DeserializeArrayIncrementally<MessagePart>(ref reader, ReadMessagePart);
break;
default:
if (!reader.Read())
{
throw new JsonException("Unexpected end of JSON while reading property value.");
}
if (!reader.TrySkip())
{
throw new JsonException("Unexpected end of JSON while skipping property value.");
}
break;
}
}
return (role ?? string.Empty, parts ?? [], partsTruncated);
}
/// <summary>
/// If the node is a JSON string that parses to a JSON object or array, return the parsed node instead.
/// </summary>
internal static JsonNode? TryParseStringJsonNode(JsonNode? node)
{
if (node?.GetValueKind() == JsonValueKind.String && node.GetValue<string>() is { } json)
{
try
{
var parsed = JsonNode.Parse(json);View on GitHub (pinned to 25830f84bd)