langchain-ai/deepagents · error · TypeError
hooks trust store must be a JSON object: {path}
Error message
hooks trust store must be a JSON object: {path} What it means
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.
Source
Thrown at libs/code/deepagents_code/hooks/trust.py:190
# Decoding happens during the read, so non-UTF-8 stores surface here
# rather than at `json.loads` below.
if strict:
raise
logger.warning("Could not read hooks trust store %s: %s", path, exc)
return HooksTrustStore()
try:
data: object = json.loads(raw_text)
except json.JSONDecodeError as exc:
if strict:
raise
logger.warning("Could not parse hooks trust store %s: %s", path, exc)
return HooksTrustStore()
if not isinstance(data, dict):
msg = f"hooks trust store must be a JSON object: {path}"
if strict:
raise TypeError(msg)
logger.warning(msg)
return HooksTrustStore()
version = data.get("version")
if version != _STORE_VERSION:
msg = f"Unsupported hooks trust store version: {version!r}"
if strict:
raise ValueError(msg)
logger.warning(
"Ignoring hooks trust store with unsupported version %r", version
)
return HooksTrustStore()
try:
projects = _parse_projects(data.get("projects"), path=path)
except TypeError:
if strict:
raiseView on GitHub (pinned to a1af029e6e)
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.
Example fix
// before
store = load_hooks_trust_store(path, strict=True) # file: ["/repo/a"] -> TypeError
// after
# fix file to:
# {"version": 1, "projects": {"/repo/a": {...}}}
store = load_hooks_trust_store(path, strict=True) Defensive patterns
Strategy: try-catch
Validate before calling
data = json.loads(store_path.read_text())
if not isinstance(data, dict):
store_path.unlink() # let library recreate an empty store Type guard
def is_store_object(data: object) -> TypeGuard[dict]:
return isinstance(data, dict) Try / catch
try:
store = load_hooks_trust_store(path, strict=True)
except TypeError as exc:
if "must be a JSON object" in str(exc):
reset_store_and_retrust(path) Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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).
Related errors
- hooks trust store projects must be an object: {path}
- MCP token file {path} is not a JSON object (found {type(data
- Skill trust store {store_path} is not a JSON object
- {source}: {_display_path(path)}: malformed tools.json: expec
- Failed to parse {SERVER_ENV_PREFIX}{suffix} as JSON: {exc}.
AI-assisted analysis of langchain-ai/deepagents@a1af029e6e (2026-08-29).
Data as JSON: /api/errors/f68a1782a2ae7a7d.
Report an issue: GitHub.