FoundationAgents/MetaGPT · error · JSONDecodeError
Expecting ':' delimiter
Error message
Expecting ':' delimiter
What it means
Raised by MetaGPT's custom decoder (metagpt/utils/custom_decoder.py) while scanning an object: after a key string is consumed, it expects the next significant character to be ':' (optionally after whitespace). If it isn't — a missing colon between key and value — JSONDecodeError('Expecting \'\:\' delimiter') is raised at that position.
Source
Thrown at metagpt/utils/custom_decoder.py:152
pairs = object_hook(pairs)
return pairs, end + 1
elif nextchar != '"':
raise JSONDecodeError("Expecting property name enclosed in double quotes", s, end)
end += 1
while True:
if end + 1 < len(s) and s[end] == nextchar and s[end + 1] == nextchar:
# Handle the case where the next two characters are the same as nextchar
key, end = scanstring(s, end + 2, strict, delimiter=nextchar * 3)
else:
# Handle the case where the next two characters are not the same as nextchar
key, end = scanstring(s, end, strict, delimiter=nextchar)
key = memo_get(key, key)
# To skip some function call overhead we optimize the fast paths where
# the JSON key separator is ": " or just ":".
if s[end : end + 1] != ":":
end = _w(s, end).end()
if s[end : end + 1] != ":":
raise JSONDecodeError("Expecting ':' delimiter", s, end)
end += 1
try:
if s[end] in _ws:
end += 1
if s[end] in _ws:
end = _w(s, end + 1).end()
except IndexError:
pass
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:View on GitHub (pinned to 11cdf466d0)
Solutions
- Look at the colno in the JSONDecodeError; the character right there should be a colon.
- Fix the source text: '{"a": 1}', '{"a": 1}'.
- For '=' style input, convert it (replace '=' with ':' before decoding) or use a YAML parser.
- Increase max_tokens / re-request if truncation cut the JSON mid-object.
Example fix
# before
loads('{"a" 1}') # missing colon
# after
loads('{"a": 1}') Defensive patterns
Strategy: try-catch
Validate before calling
import re
def fix_missing_colons(text: str) -> str:
return re.sub(r'("(?:[^"\\]|\\.)*")\s+(?=["\[\{\d\wtfn])', r'\1:', text) # heuristic 'key" value' -> 'key": value' Try / catch
from json import JSONDecodeError
try:
obj = loads(text)
except JSONDecodeError as e:
if e.msg == "Expecting ':' delimiter":
# inspect text at (e.lineno, e.colno); repair '=' or missing ':' and retry Prevention
- Reject JS/YAML-style output ('=', missing colons) from the model with explicit JSON schema examples.
- Check truncation: input ending right after a key also produces this error.
- Use colno to verify the exact character where the colon was expected.
When it happens
Trigger: Decoding '{"a" 1}' (colon omitted); '{"a" = 1}' (equals sign, YAML/JS habit); '{"a", "b": 1}' (comma where colon belongs); a truncated string like '{"key"' where the input ends before the colon.
Common situations: LLM writes JS-object or YAML-flavored syntax inside JSON; hand-typed config files with '=' instead of ':'; response truncated by max_tokens right after the key token.
Related errors
- Expecting property name enclosed in double quotes
- Cannot find the answer phrase "{response}"
- Invalid python code
- Could not find content between [{tag}] and [/{tag}]
- Error while extracting and parsing the {data_type}: {e}
AI-assisted analysis of FoundationAgents/MetaGPT@11cdf466d0 (2026-08-14).
Data as JSON: /api/errors/1e05474e9d230351.
Report an issue: GitHub.