langchain-ai/deepagents · error · ValueError

Skill trust store {store_path} is not a JSON object

Error message

Skill trust store {store_path} is not a JSON object

What it means

`_load_store` parses the skill trust store JSON. In strict mode, if the top-level JSON value is not an object (e.g. a list, string, or number), it raises `ValueError` with this message; in non-strict mode it logs a warning and treats the store as empty. Strict readers (like `skills trust list`) prefer failing loudly over silently ignoring a corrupt store.

Source

Thrown at libs/code/deepagents_code/skills/trust.py:170

        # re-prompt, so log at WARNING (not DEBUG) to leave a breadcrumb for
        # the otherwise-unexplained re-prompt.
        logger.warning(
            "Skill trust store %s is corrupt; treating as empty: %s", store_path, exc
        )
        return {}
    except OSError as exc:
        if strict:
            raise
        logger.warning(
            "Could not read skill trust store %s; treating as empty: %s",
            store_path,
            exc,
        )
        return {}
    if not isinstance(data, dict):
        if strict:
            msg = f"Skill trust store {store_path} is not a JSON object"
            raise ValueError(msg)
        logger.warning(
            "Skill trust store %s is not a JSON object; ignoring", store_path
        )
        return {}
    # A store written by a newer build may carry an incompatible schema. Reading
    # its `dirs` regardless could misinterpret entries, so refuse: fail-closed
    # (treat as nothing trusted) for enforcement, and surface the error for the
    # audit path. A present-but-non-integer `version` is unrecognized in the same
    # way (only tampering or a corrupt write produces it, since every writer
    # stamps an int), so it is refused too rather than falling through and
    # trusting `dirs`. A missing `version` stays tolerated: an empty `{}` file
    # has no `dirs` to trust anyway. Together this makes the `_STORAGE_VERSION`
    # "bump on incompatible changes" contract enforceable rather than
    # aspirational.
    version = data.get("version")
    if version is not None and (
        not isinstance(version, int) or version > _STORAGE_VERSION
    ):

View on GitHub (pinned to a1af029e6e)

Solutions

  1. Inspect the trust store file and fix its top level to be a JSON object of directory entries
  2. Back up and delete the corrupt store so it is recreated empty, then re-trust directories with `skills trust add`
  3. Avoid hand-editing the file; use the `skills trust` CLI subcommands
  4. Check for writers (other tool versions) that may serialize the store in a different shape

Example fix

// before (trust.json)
["/home/me/skills"]
// after
{"version": 1, "dirs": {"/home/me/skills": {}}  # object shape expected by this build
Defensive patterns

Strategy: type-guard

Validate before calling

import json
from pathlib import Path

def store_is_object(store: Path) -> bool:
    try:
        return isinstance(json.loads(store.read_text(encoding='utf-8')), dict)
    except (OSError, ValueError):
        return False

Type guard

def is_trust_store_shape(data: object) -> bool:
    return isinstance(data, dict)

Try / catch

try:
    dirs = _read_dirs(store_path)  # strict read
except ValueError as exc:
    print(f'trust store corrupt ({exc}); recreating')
    store_path.unlink(missing_ok=True)
    dirs = {}

Prevention

When it happens

Trigger: Calling `trust_skill_dir`, `revoke_skill_dir_trust`, or `_read_dirs` (which uses strict reads) when the trust store file contains valid JSON whose top level is an array or scalar instead of an object.

Common situations: Hand-editing the trust file and saving a bare list of paths; a tool rewriting the file in the wrong shape; truncated or mangled writes from a crash or disk-full leaving non-object content.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


AI-assisted analysis of langchain-ai/deepagents@a1af029e6e (2026-08-29). Data as JSON: /api/errors/cddc957bccf43289. Report an issue: GitHub.