{"record":{"id":"f68a1782a2ae7a7d","repo":"langchain-ai/deepagents","slug":"hooks-trust-store-must-be-a-json-object-path","errorCode":null,"errorMessage":"hooks trust store must be a JSON object: {path}","messagePattern":"hooks trust store must be a JSON object: (.+?)","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"libs/code/deepagents_code/hooks/trust.py","lineNumber":190,"sourceCode":"        # Decoding happens during the read, so non-UTF-8 stores surface here\n        # rather than at `json.loads` below.\n        if strict:\n            raise\n        logger.warning(\"Could not read hooks trust store %s: %s\", path, exc)\n        return HooksTrustStore()\n\n    try:\n        data: object = json.loads(raw_text)\n    except json.JSONDecodeError as exc:\n        if strict:\n            raise\n        logger.warning(\"Could not parse hooks trust store %s: %s\", path, exc)\n        return HooksTrustStore()\n\n    if not isinstance(data, dict):\n        msg = f\"hooks trust store must be a JSON object: {path}\"\n        if strict:\n            raise TypeError(msg)\n        logger.warning(msg)\n        return HooksTrustStore()\n\n    version = data.get(\"version\")\n    if version != _STORE_VERSION:\n        msg = f\"Unsupported hooks trust store version: {version!r}\"\n        if strict:\n            raise ValueError(msg)\n        logger.warning(\n            \"Ignoring hooks trust store with unsupported version %r\", version\n        )\n        return HooksTrustStore()\n\n    try:\n        projects = _parse_projects(data.get(\"projects\"), path=path)\n    except TypeError:\n        if strict:\n            raise","sourceCodeStart":172,"sourceCodeEnd":208,"githubUrl":"https://github.com/langchain-ai/deepagents/blob/a1af029e6e73cb17c36bff823d227747b28e91e1/libs/code/deepagents_code/hooks/trust.py#L172-L208","documentation":"The hooks trust store file itself must be a JSON object with store metadata. _load_store raises TypeError in strict mode when the parsed file is any other JSON type (array, string, number), and returns an empty store with a warning otherwise. This guards against corrupt or foreign files at the trust-store path.","triggerScenarios":"is_project_hooks_trusted or trust_project_hooks loads a store file whose JSON parses to a non-dict (e.g. a top-level array from an old/foreign format) with strict=True; in non-strict mode this is only a warning.","commonSituations":"Trust store path pointing at the wrong file (e.g. an unrelated JSON array); a tool writing a different schema; manual edits replacing the object with a list; truncated/corrupt writes (though unparsable JSON is handled earlier).","solutions":["Restore the store to an object shape: {\"version\": <expected>, \"projects\": {...}}.","Delete the bad store file so the library recreates it, then re-trust the project.","Point the trust-store path configuration at the correct file.","Call with strict=False if you only need a best-effort check and want a warning plus empty store instead of an exception."],"exampleFix":"// before\nstore = load_hooks_trust_store(path, strict=True)  # file: [\"/repo/a\"] -> TypeError\n\n// after\n# fix file to:\n# {\"version\": 1, \"projects\": {\"/repo/a\": {...}}}\nstore = load_hooks_trust_store(path, strict=True)","handlingStrategy":"try-catch","validationCode":"data = json.loads(store_path.read_text())\nif not isinstance(data, dict):\n    store_path.unlink()  # let library recreate an empty store","typeGuard":"def is_store_object(data: object) -> TypeGuard[dict]:\n    return isinstance(data, dict)","tryCatchPattern":"try:\n    store = load_hooks_trust_store(path, strict=True)\nexcept TypeError as exc:\n    if \"must be a JSON object\" in str(exc):\n        reset_store_and_retrust(path)","preventionTips":["Confirm the trust-store path points at the library-managed file","Keep the top-level JSON an object with version and projects keys","Use strict=False for advisory checks where an empty store is acceptable","Recreate the store instead of hand-converting foreign formats"],"tags":["trust","schema-validation","json"],"backgroundTag":"trust-store-corrupt","analyzedSha":"a1af029e6e73cb17c36bff823d227747b28e91e1","analyzedAt":"2026-08-29T11:43:24.718Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}