FoundationAgents/MetaGPT · error · JSONDecodeError
Expecting ',' delimiter
Error message
Expecting ',' delimiter
What it means
Raised by the custom decoder's object scanner: after successfully reading a key/value pair, the next non-whitespace character was neither '}' (end of object) nor ',' (pair separator). It is the standard 'missing comma between object members' JSON syntax error, surfaced from MetaGPT's tolerant decoder.
Source
Thrown at metagpt/utils/custom_decoder.py:180
try:
value, end = scan_once(s, end)
except StopIteration as err:
raise JSONDecodeError("Expecting value", s, err.value) from None
pairs_append((key, value))
try:
nextchar = s[end]
if nextchar in _ws:
end = _w(s, end + 1).end()
nextchar = s[end]
except IndexError:
nextchar = ""
end += 1
if nextchar == "}":
break
elif nextchar != ",":
raise JSONDecodeError("Expecting ',' delimiter", s, end - 1)
end = _w(s, end).end()
nextchar = s[end : end + 1]
end += 1
if nextchar != '"':
raise JSONDecodeError("Expecting property name enclosed in double quotes", s, end - 1)
if object_pairs_hook is not None:
result = object_pairs_hook(pairs)
return result, end
pairs = dict(pairs)
if object_hook is not None:
pairs = object_hook(pairs)
return pairs, end
def py_scanstring(s, end, strict=True, _b=BACKSLASH, _m=STRINGCHUNK.match, delimiter='"'):
"""Scan the string s for a JSON string.
Args:View on GitHub (pinned to 11cdf466d0)
Solutions
- Go to the column given in the error (end - 1) and add the missing ',' between the two members.
- Escape inner double quotes inside string values (\") so the comma is not consumed as part of the value.
- Validate strings with a linter/json.parse before passing them to the decoder.
- For LLM output, re-request or run through a JSON repair step before decoding.
Example fix
// before
'{"name": "a" "value": 1}' -> JSONDecodeError: Expecting ',' delimiter
// after
'{"name": "a", "value": 1}' Defensive patterns
Strategy: try-catch
Validate before calling
import json
def object_members_comma_separated(text: str) -> bool:
try:
json.loads(text)
return True
except json.JSONDecodeError:
return False Try / catch
try:
obj = decoder.decode(s)
except json.JSONDecodeError as e:
if e.msg == "Expecting ',' delimiter":
s2 = s[:e.pos] + ',' + s[e.pos:] # targeted repair candidate
obj = decoder.decode(s2) Prevention
- Use a JSON linter/IDE validation on hand-edited strings.
- Escape inner double quotes inside string values.
- Generate JSON with json.dumps rather than templates.
When it happens
Trigger: Decoding an object like {"a":1 "b":2} (missing comma), {"a":1;"b":2} (semicolon separator), or text where a quoted string value swallowed the comma because of an unescaped inner quote.
Common situations: LLM-generated JSON with omitted commas, hand-edited config strings, or nested quotes inside string values that terminate the string early and leave a stray token before the comma.
Related errors
- Expecting property name enclosed in double quotes
- Expecting ':' delimiter
- Expecting value
- Unterminated string starting at
- Invalid control character {0!r} at
AI-assisted analysis of FoundationAgents/MetaGPT@11cdf466d0 (2026-08-14).
Data as JSON: /api/errors/0358f7b98d74cf17.
Report an issue: GitHub.