mem0ai/mem0 · error · Error
Config is not a JSON object
Error message
Config is not a JSON object
What it means
Internal sentinel thrown while parsing ~/.openclaw/openclaw.json when the file parses as valid JSON but is not a plain object (null, array, number, string, boolean). It never surfaces raw: the surrounding catch rewraps it into the '[openclaw-mem0] Failed to parse ...' error, so users only see error 24. It exists to distinguish 'wrong shape' from 'syntax error' in the message.
Source
Thrown at integrations/openclaw/cli/config-file.ts:65
* Returns {} only when the file doesn't exist (first-time setup).
* Throws on parse errors to prevent writes from destroying existing config.
*/
function readFullConfig(): Record<string, unknown> {
if (!exists(OPENCLAW_CONFIG_FILE)) {
return {};
}
const text = readText(OPENCLAW_CONFIG_FILE);
// Handle empty or whitespace-only files as first-time setup
if (!text.trim()) {
return {};
}
try {
const parsed = JSON.parse(text);
if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) {
throw new Error("Config is not a JSON object");
}
return parsed;
} catch (err) {
// Fail closed: throw so writes don't proceed with empty config
const msg = err instanceof Error ? err.message : String(err);
throw new Error(
`[openclaw-mem0] Failed to parse ${OPENCLAW_CONFIG_FILE}: ${msg}\n` +
`Fix the JSON syntax error manually before running config commands.`,
);
}
}
/**
* Write the full ~/.openclaw/openclaw.json.
*
* Re-reads the file immediately before writing and deep-merges the
* `plugins` section so that fields written by other processes (e.g.
* OpenClaw gateway adding `installs`, `slots`) are not clobbered.View on GitHub (pinned to 001c235229)
Solutions
- Open ~/.openclaw/openclaw.json and make the top-level value a JSON object: { ... }.
- If the file is unrecoverable, back it up and delete it — readText treats a missing/empty file as first-time setup and recreates {}.
- Validate with `jq type ~/.openclaw/openclaw.json` — it must print 'object'.
Example fix
// before ~/.openclaw/openclaw.json
[
{ "mode": "platform" }
]
// after
{
"plugins": {
"openclaw-mem0": { "mode": "platform" }
}
} Defensive patterns
Strategy: validation
Validate before calling
const parsed = JSON.parse(text);
if (parsed === null || typeof parsed !== 'object' || Array.isArray(parsed)) {
// reject before use
} Type guard
function isJsonObject(v: unknown): v is Record<string, unknown> {
return typeof v === 'object' && v !== null && !Array.isArray(v);
} Prevention
- Validate openclaw.json with `jq type` (must output 'object') after manual edits.
- Never store a JSON array at the top level of the config file.
When it happens
Trigger: The config file containing a JSON array at top level (e.g. []), a bare string, a number, or literal null. The empty-file case is handled earlier (returns {} for first-time setup), so this only fires on non-empty, syntactically valid, non-object JSON.
Common situations: User edited openclaw.json and replaced the object with an array of settings; another tool wrote a JSON scalar to the file; hand-crafting config from a snippet that was itself a list.
Related errors
- [openclaw-mem0] Failed to parse ${OPENCLAW_CONFIG_FILE}: ${m
- Unknown LLM provider: ${providerId}
- Unknown embedder provider: ${providerId}
- ${label} has unknown keys: ${unknown.join(", ")}
- openclaw-mem0 config required
AI-assisted analysis of mem0ai/mem0@001c235229 (2026-08-15).
Data as JSON: /api/errors/ac51a88a7de54e0a.
Report an issue: GitHub.