{"record":{"id":"d48f6c8ee52d08ce","repo":"langchain-ai/deepagents","slug":"hooks-trust-store-projects-must-be-an-object-pat","errorCode":null,"errorMessage":"hooks trust store projects must be an object: {path}","messagePattern":"hooks trust store projects must be an object: (.+?)","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"libs/code/deepagents_code/hooks/trust.py","lineNumber":125,"sourceCode":"    \"\"\"Parse trust entries, skipping structurally invalid ones.\n\n    Args:\n        raw_projects: Raw `projects` value from JSON.\n        path: Store path used in warning messages.\n\n    Returns:\n        Validated project map. Empty when `raw_projects` is missing or not a\n        mapping.\n\n    Raises:\n        TypeError: When `raw_projects` is present but not a mapping (strict\n            callers refuse to overwrite such stores).\n    \"\"\"\n    if raw_projects is None:\n        return {}\n    if not isinstance(raw_projects, dict):\n        msg = f\"hooks trust store projects must be an object: {path}\"\n        raise TypeError(msg)\n\n    projects: dict[str, HooksTrustEntry] = {}\n    for key, value in raw_projects.items():\n        if not isinstance(key, str):\n            logger.warning(\n                \"Skipping non-string hooks trust project key in %s: %r\",\n                path,\n                key,\n            )\n            continue\n        try:\n            projects[key] = HooksTrustEntry.model_validate(value)\n        except ValidationError as exc:\n            logger.warning(\n                \"Skipping invalid hooks trust entry for %s in %s: %s\",\n                key,\n                path,\n                exc,","sourceCodeStart":107,"sourceCodeEnd":143,"githubUrl":"https://github.com/langchain-ai/deepagents/blob/a1af029e6e73cb17c36bff823d227747b28e91e1/libs/code/deepagents_code/hooks/trust.py#L107-L143","documentation":"The hooks trust store file's \"projects\" key must map project paths to trust entry objects. _parse_projects raises TypeError when the parsed JSON has a non-object at that position (e.g. a list or string), naming the offending store path, because per-project trust cannot be read from any other shape.","triggerScenarios":"Loading a trust store whose top-level JSON is an object but whose \"projects\" field is a list, string, number, or null-typed non-dict (raw_projects not None and not a dict) during _load_store -> _parse_projects.","commonSituations":"Hand-editing the trust store JSON and writing projects as an array; a migration or older tool writing the legacy flat format; corruption by concurrent writes or editors.","solutions":["Fix the store file so \"projects\" is a JSON object: {\"projects\": {\"/path/to/project\": {...entry...}}}.","Delete the corrupted store and let the library recreate it, then re-approve trust via the trust flow (trust_project_hooks).","Back up the file before editing and validate JSON shape after edits.","Catch TypeError at load time and prompt the user to re-trust rather than crashing."],"exampleFix":"// before\n{\"version\": 1, \"projects\": [\"/repo/a\"]}   // list -> TypeError\n\n// after\n{\"version\": 1, \"projects\": {\"/repo/a\": {\"trusted_at\": \"2026-01-01T00:00:00Z\"}}}","handlingStrategy":"validation","validationCode":"data = json.loads(store_path.read_text())\nif not isinstance(data.get(\"projects\", {}), dict):\n    repair_or_reset_store(store_path)","typeGuard":"def has_valid_projects(data: object) -> TypeGuard[dict]:\n    return isinstance(data, dict) and isinstance(data.get(\"projects\", {}), dict)","tryCatchPattern":"try:\n    store = load_hooks_trust_store(path)\nexcept TypeError as exc:\n    if \"must be an object\" in str(exc):\n        backup_and_reset_store(path)  # recreate + re-trust","preventionTips":["Edit the trust store only as {\"projects\": {path: entry}} objects","Back up and JSON-validate after manual edits","Don't write arrays/lists under \"projects\"","Reset the store rather than hand-repairing when unsure"],"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"}