TencentCloud/TencentDB-Agent-Memory · warning
Failed to parse ${configPath} — please add hooks.allowConver
Error message
Failed to parse ${configPath} — please add hooks.allowConversationAccess manually What it means
manualPatch in ensure-hook-policy.ts reads the plugin config file and tries to parse it with JSON5 before injecting the hooks.allowConversationAccess policy. When the file cannot be read or parsed (malformed JSON/JSON5 syntax), it logs this warning and returns without modifying anything, deferring the fix to the developer. The library refuses to rewrite a config it cannot parse, since a blind rewrite could destroy user data.
Source
Thrown at MemoryCore/src/utils/ensure-hook-policy.ts:233
// Fallback: manual file write
manualPatch(logger);
}
function manualPatch(logger: Logger): void {
const TAG = "[memory-tdai] [hook-policy]";
const configPath = resolveConfigPath();
if (!configPath) {
logger.warn(`${TAG} Cannot locate openclaw.json — please add hooks.allowConversationAccess manually`);
return;
}
let parsed: Record<string, unknown>;
try {
const raw = fs.readFileSync(configPath, "utf-8");
parsed = JSON5.parse(raw);
} catch {
logger.warn(`${TAG} Failed to parse ${configPath} — please add hooks.allowConversationAccess manually`);
return;
}
if (hasPolicyAlready(parsed)) return;
if ("$include" in parsed || (isObj(parsed.plugins) && "$include" in parsed.plugins)) {
logger.warn(`${TAG} Config uses $include — please add manually: plugins.entries.${PLUGIN_ID}.hooks.allowConversationAccess = true`);
return;
}
if (!isObj(parsed.plugins)) parsed.plugins = {};
const plugins = parsed.plugins as Record<string, unknown>;
if (!isObj(plugins.entries)) plugins.entries = {};
const entries = plugins.entries as Record<string, unknown>;
if (!isObj(entries[PLUGIN_ID])) entries[PLUGIN_ID] = {};
const entry = entries[PLUGIN_ID] as Record<string, unknown>;
if (!isObj(entry.hooks)) entry.hooks = {};
(entry.hooks as Record<string, unknown>).allowConversationAccess = true;View on GitHub (pinned to 3efcd317b8)
Solutions
- Open configPath and fix the JSON5 syntax error (validate with a JSON5 parser)
- Confirm the file exists at configPath and the process has read access
- After making the file parseable, add plugins.entries.<PLUGIN_ID>.hooks.allowConversationAccess = true yourself or rerun ensurePluginHookPolicy
- If the file is corrupted beyond repair, restore it from backup or regenerate it, then re-run the policy check
Example fix
// before (config.json)
{
"plugins": { "entries": { "my-plugin": { },, } }
}
// after
{
"plugins": {
"entries": {
"my-plugin": { "hooks": { "allowConversationAccess": true } }
}
}
} Defensive patterns
Strategy: fallback
Validate before calling
function canParseConfig(configPath: string): boolean {
try { JSON5.parse(fs.readFileSync(configPath, 'utf-8')); return true; } catch { return false; }
} Type guard
function isParseableConfigFile(path: string): path is string {
try { JSON5.parse(fs.readFileSync(path, 'utf-8')); return true; } catch { return false; }
} Try / catch
try {
ensurePluginHookPolicy(configPath);
} catch (err) {
logger.warn(`Could not apply hook policy to ${configPath}; fix the config manually`, { err });
} Prevention
- Validate the config with a JSON5 parser after each manual edit
- Keep the config in version control to detect corruption early
- Verify file permissions and that configPath points to the real config
When it happens
Trigger: Calling ensurePluginHookPolicy when configPath contains invalid JSON5 (trailing commas beyond JSON5 rules, unquoted keys, truncated file), the file does not exist, or has encoding/read permission problems — the readFileSync or JSON5.parse throws and the catch block emits the warning.
Common situations: Hand-edited config with a syntax typo; a partially written/corrupted config after a crash; wrong configPath passed; file locked or unreadable due to permissions; user pasted JSON with an accidental BOM or stray characters.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- redis config is required when state_backend=redis
- [state-backend] Redis integration is not available — install
- invalid_param_value
- unknown_module
- invalid_param_scope
AI-assisted analysis of TencentCloud/TencentDB-Agent-Memory@3efcd317b8 (2026-09-01).
Data as JSON: /api/errors/80a65584c409737f.
Report an issue: GitHub.