{"record":{"id":"eda87e16b37b50f3","repo":"langchain-ai/deepagents","slug":"workspace-config-must-be-an-object","errorCode":null,"errorMessage":"workspace_config must be an object","messagePattern":"workspace_config must be an object","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"libs/code/deepagents_code/workspace.py","lineNumber":108,"sourceCode":"    if os.name != \"nt\":\n        from deepagents.backends.utils import validate_path\n\n        validate_path(str(resolved))\n    return resolved\n\n\ndef canonical_workspace_config(value: object | None) -> tuple[str, str]:\n    \"\"\"Return bounded canonical JSON and its SHA-256 fingerprint.\n\n    Raises:\n        TypeError: If the configuration is not an object.\n        ValueError: If it cannot be serialized or exceeds the size limit.\n    \"\"\"\n    if value is None:\n        value = {}\n    if not isinstance(value, dict):\n        msg = \"workspace_config must be an object\"\n        raise TypeError(msg)\n    try:\n        serialized = json.dumps(value, sort_keys=True, separators=(\",\", \":\"))\n    except (TypeError, ValueError) as exc:\n        msg = \"workspace configuration must be JSON serializable\"\n        raise ValueError(msg) from exc\n    if len(serialized) > _MAX_CONFIG_LENGTH:\n        msg = \"workspace configuration is too large\"\n        raise ValueError(msg)\n    return serialized, hashlib.sha256(serialized.encode()).hexdigest()\n\n\ndef _fingerprint(value: object) -> str:\n    serialized = json.dumps(value, sort_keys=True, separators=(\",\", \":\"))\n    return hashlib.sha256(serialized.encode()).hexdigest()\n\n\ndef resolve_workspace(\n    cwd: object,","sourceCodeStart":90,"sourceCodeEnd":126,"githubUrl":"https://github.com/langchain-ai/deepagents/blob/a1af029e6e73cb17c36bff823d227747b28e91e1/libs/code/deepagents_code/workspace.py#L90-L126","documentation":"`canonical_workspace_config` normalizes an optional workspace config into a canonical serialized form plus fingerprint. This library raises this TypeError when the caller passes a non-dict, non-None value (e.g. a list, string, or number) as `workspace_config`, because the config must be a JSON object of key/value settings.","triggerScenarios":"Calling `canonical_workspace_config` directly, or `bind_thread_workspace` / `resolve_workspace` / `require_thread_workspace`, with `workspace_config` set to a JSON array, string, int, or None-wrapped object instead of a dict (e.g. loading config from YAML that yields a list, or passing `workspace_config='{}'` as a JSON string).","commonSituations":"Config loaded from a YAML file that parses to a list at top level; JSON config passed as a raw string instead of `json.loads`-ed; a caller wrapping the dict in an extra container; refactored code that changed the config shape.","solutions":["Ensure the value passed as `workspace_config` is a `dict` (or omitted/None for defaults)","If loading from a string or file, `json.loads` it first and assert the top level is an object","If your config is a list, wrap or restructure it under an object key"],"exampleFix":"// before\nresolve_workspace(cwd, workspace_config=[\"a\", \"b\"])\n// after\nresolve_workspace(cwd, workspace_config={\"allowed_paths\": [\"a\", \"b\"]})","handlingStrategy":"type-guard","validationCode":"if workspace_config is not None and not isinstance(workspace_config, dict):\n    raise TypeError(\"workspace_config must be a dict\")","typeGuard":"def is_workspace_config(v: object) -> TypeGuard[dict[str, Any]]:\n    return v is None or isinstance(v, dict)","tryCatchPattern":"try:\n    resolve_workspace(cwd, workspace_config)\nexcept TypeError as exc:\n    logging.error(\"bad workspace_config type: %s\", exc)\n    workspace_config = {}","preventionTips":["Only pass dicts or None as workspace_config","json.loads string configs before passing","Validate YAML-loaded configs are mappings at top level"],"tags":["workspace","type-error","validation","config"],"backgroundTag":"invalid-workspace-config","analyzedSha":"a1af029e6e73cb17c36bff823d227747b28e91e1","analyzedAt":"2026-08-29T11:43:24.718Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}