iOfficeAI/OfficeCLI · warning · JsonException
Expected property name
Error message
Expected property name
What it means
JsonException from LenientStringDictionaryConverter.Read inside the OBJECT branch: after reading a value and looping, the next token was not a PropertyName (e.g. a value token appeared where a property name was expected). This indicates a structurally malformed props object, not a value-type problem.
Source
Thrown at src/officecli/BatchTypes.cs:41
{
while (reader.Read())
{
if (reader.TokenType == JsonTokenType.EndArray) return dict;
if (reader.TokenType != JsonTokenType.String)
throw new JsonException("Expected \"key=value\" string in props array");
var kv = reader.GetString()!;
var eq = kv.IndexOf('=');
if (eq > 0) dict[kv[..eq]] = kv[(eq + 1)..]; // skip malformed, as ParseProps does
}
throw new JsonException("Unexpected end of JSON");
}
if (reader.TokenType != JsonTokenType.StartObject)
throw new JsonException("Expected object or [\"key=value\"] array for props");
while (reader.Read())
{
if (reader.TokenType == JsonTokenType.EndObject) return dict;
if (reader.TokenType != JsonTokenType.PropertyName)
throw new JsonException("Expected property name");
var key = reader.GetString()!;
reader.Read();
var value = reader.TokenType switch
{
JsonTokenType.String => reader.GetString()!,
JsonTokenType.Number => reader.TryGetInt64(out var l) ? l.ToString() : reader.GetDouble().ToString(),
JsonTokenType.True => "true",
JsonTokenType.False => "false",
JsonTokenType.Null => "",
_ => throw new JsonException($"Unexpected token {reader.TokenType} for prop value '{key}'")
};
dict[key] = value;
}
throw new JsonException("Unexpected end of JSON");
}
public override void Write(Utf8JsonWriter writer, Dictionary<string, string> value, JsonSerializerOptions options)
{View on GitHub (pinned to 1ced45e900)
Solutions
- Re-emit props with a real JSON serializer so key/value pairing is guaranteed.
- Run the full batch through a JSON validator/linter before sending.
- Confirm every props entry is "key": value, comma-separated.
Example fix
// before: props: { "text": "hi" "count" } // malformed (missing value)
// after: props: { "text": "hi", "count": "3" } Defensive patterns
Strategy: validation
Validate before calling
// Structural pre-check: every props entry must be a string scalar value
function wellFormedPropsObject(p) {
if (p == null || typeof p !== 'object' || Array.isArray(p)) return false;
return Object.entries(p).every(([k, v]) => typeof k === 'string' && ['string','number','boolean'].includes(typeof v));
} Prevention
- Always serialize props with JSON.stringify so key/value pairing is enforced.
- Lint batch JSON before sending.
- Avoid hand-editing batch item JSON.
When it happens
Trigger: A props object like {"a":1 2} (a number where the next key should be), {"a":"b" "c"} (two strings in a row), or any object whose key/value pairing is broken.
Common situations: Hand-edited or templated JSON with a missing key or extra value; a serializer bug that emitted values back-to-back.
Related errors
- Expected "key=value" string in props array
- Unexpected end of JSON
- Expected object or ["key=value"] array for props
- Unexpected token {reader.TokenType} for prop value '{key}'
- Expected PropertyName
AI-assisted analysis of iOfficeAI/OfficeCLI@1ced45e900 (2026-08-13).
Data as JSON: /api/errors/d4fe8e1a06695dbf.
Report an issue: GitHub.