{"record":{"id":"dbe3b6559d550a9c","repo":"TencentCloud/TencentDB-Agent-Memory","slug":"cannot-locate-openclaw-json-please-add-hooks-all","errorCode":null,"errorMessage":"Cannot locate openclaw.json — please add hooks.allowConversationAccess manually","messagePattern":"Cannot locate openclaw\\.json — please add hooks\\.allowConversationAccess manually","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"MemoryCore/src/utils/ensure-hook-policy.ts","lineNumber":224,"sourceCode":"    }).then(() => {\n      logger.info(`${TAG} ✅ Patched via SDK — gateway will restart automatically.`);\n    }).catch((err: unknown) => {\n      logger.warn(`${TAG} SDK mutateConfigFile failed: ${err instanceof Error ? err.message : String(err)}, trying manual fallback...`);\n      manualPatch(logger);\n    });\n    return;\n  }\n\n  // Fallback: manual file write\n  manualPatch(logger);\n}\n\nfunction manualPatch(logger: Logger): void {\n  const TAG = \"[memory-tdai] [hook-policy]\";\n\n  const configPath = resolveConfigPath();\n  if (!configPath) {\n    logger.warn(`${TAG} Cannot locate openclaw.json — please add hooks.allowConversationAccess manually`);\n    return;\n  }\n\n  let parsed: Record<string, unknown>;\n  try {\n    const raw = fs.readFileSync(configPath, \"utf-8\");\n    parsed = JSON5.parse(raw);\n  } catch {\n    logger.warn(`${TAG} Failed to parse ${configPath} — please add hooks.allowConversationAccess manually`);\n    return;\n  }\n\n  if (hasPolicyAlready(parsed)) return;\n\n  if (\"$include\" in parsed || (isObj(parsed.plugins) && \"$include\" in parsed.plugins)) {\n    logger.warn(`${TAG} Config uses $include — please add manually: plugins.entries.${PLUGIN_ID}.hooks.allowConversationAccess = true`);\n    return;\n  }","sourceCodeStart":206,"sourceCodeEnd":242,"githubUrl":"https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/3efcd317b84146d6a08518ac0f7ee7c8a8d200ec/MemoryCore/src/utils/ensure-hook-policy.ts#L206-L242","documentation":"manualPatch is the fallback writer for the plugin's hook policy: when the SDK's mutateConfigFile is unavailable or failed, it edits openclaw.json directly to set plugins.entries.<pluginId>.hooks.allowConversationAccess = true. This warning is logged — and patching aborted — when resolveConfigPath() cannot find the openclaw.json config file anywhere it looks, so the user must add the policy by hand.","triggerScenarios":"ensurePluginHookPolicy detects the policy is missing, the SDK mutateConfigFile path is absent or rejects (falling through to manualPatch), and resolveConfigPath() returns null because openclaw.json does not exist in the expected locations (e.g. running outside a real OpenClaw gateway workspace, custom OPENCLAW_CONFIG_PATH-style env not set, or the config file was renamed/deleted).","commonSituations":"Running the plugin in a non-standard install directory where the gateway config lives elsewhere; fresh machine without openclaw.json yet; CI/container where the home/config directory is not mounted; config split via $include so the resolver skips it (a related but distinct warning).","solutions":["Create or locate openclaw.json in the gateway's config directory and ensure the process has read access.","Manually add the policy: set plugins.entries.\"memory-tencentdb\".hooks.allowConversationAccess = true in openclaw.json, then restart the gateway.","Check that whatever mechanism resolveConfigPath() uses (env var / well-known paths) matches your install; set the config path explicitly if supported.","Prefer fixing the SDK path — ensure the host provides runtimeConfig.mutateConfigFile so the manual fallback is never needed.","If running outside a gateway (tests, CLI), ignore: ensurePluginHookPolicy only acts on gateway start, and this warning is benign there."],"exampleFix":"// before: openclaw.json missing the policy\n{\n  \"plugins\": { \"entries\": { \"memory-tencentdb\": {} } }\n}\n// after: add it manually when auto-patch cannot find the file\n{\n  \"plugins\": {\n    \"entries\": {\n      \"memory-tencentdb\": {\n        \"hooks\": { \"allowConversationAccess\": true }\n      }\n    }\n  }\n}","handlingStrategy":"validation","validationCode":"import fs from \"node:fs\";\nconst candidates = [\n  process.env.OPENCLAW_CONFIG_PATH,\n  \"./openclaw.json\",\n  \"~/.openclaw/openclaw.json\",\n].filter(Boolean) as string[];\nconst found = candidates.find((p) => fs.existsSync(p));\nif (!found) {\n  console.warn(\"openclaw.json not found — add plugins.entries.<id>.hooks.allowConversationAccess = true manually\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  ensurePluginHookPolicy({ rootConfig, runtimeConfig, logger });\n} catch (err) {\n  logger.warn(`hook policy check failed: ${err instanceof Error ? err.message : err} — verify hooks.allowConversationAccess in openclaw.json`);\n}","preventionTips":["Provision openclaw.json in the gateway config directory before installing the plugin.","Set the config-path environment variable explicitly in containers/CI where home dirs are not mounted.","Prefer the SDK path: ensure the host supplies runtimeConfig.mutateConfigFile so manual file patching is never needed.","After any gateway restart, check logs for '[hook-policy] allowConversationAccess is already active' to confirm the policy stuck."],"tags":["configuration","file-not-found","permissions","openclaw"],"backgroundTag":"config-file-not-found","analyzedSha":"3efcd317b84146d6a08518ac0f7ee7c8a8d200ec","analyzedAt":"2026-09-01T05:44:22.276Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}