{"record":{"id":"ec890414f79dbed7","repo":"langchain-ai/langgraph","slug":"cannot-json-serialize-type-object-obj-r-did-yo","errorCode":null,"errorMessage":"Cannot JSON-serialize type object: {obj!r}. Did you mean to pass an instance of the object instead?\nReceived type: {obj!r}","messagePattern":"Cannot JSON-serialize type object: (.+?)\\. Did you mean to pass an instance of the object instead\\?\nReceived type: (.+?)","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"libs/sdk-py/langgraph_sdk/_shared/utilities.py","lineNumber":76,"sourceCode":"        if header in custom_headers:\n            raise ValueError(f\"Cannot set reserved header '{header}'\")\n\n    headers = {\n        \"User-Agent\": f\"langgraph-sdk-py/{langgraph_sdk.__version__}\",\n        **custom_headers,\n    }\n    resolved_api_key = _get_api_key(api_key)\n    if resolved_api_key:\n        headers[\"x-api-key\"] = resolved_api_key\n\n    return headers\n\n\ndef _orjson_default(obj: Any) -> Any:\n    is_class = isinstance(obj, type)\n    if hasattr(obj, \"model_dump\") and callable(obj.model_dump):\n        if is_class:\n            raise TypeError(\n                f\"Cannot JSON-serialize type object: {obj!r}. Did you mean to pass an instance of the object instead?\"\n                f\"\\nReceived type: {obj!r}\"\n            )\n        return obj.model_dump()\n    elif hasattr(obj, \"dict\") and callable(obj.dict):\n        if is_class:\n            raise TypeError(\n                f\"Cannot JSON-serialize type object: {obj!r}. Did you mean to pass an instance of the object instead?\"\n                f\"\\nReceived type: {obj!r}\"\n            )\n        return obj.dict()\n    elif isinstance(obj, (set, frozenset)):\n        return list(obj)\n    else:\n        raise TypeError(f\"Object of type {type(obj)} is not JSON serializable\")\n\n\n# Compiled regex pattern for extracting run metadata from Content-Location header","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/langchain-ai/langgraph/blob/38031739e551638e373fb553453256c23feeb41f/libs/sdk-py/langgraph_sdk/_shared/utilities.py#L58-L94","documentation":"Error \"Cannot JSON-serialize type object: {obj!r}. Did you mean to pass an instance of the object instead?\nReceived type: {obj!r}\" thrown in langchain-ai/langgraph.","triggerScenarios":"Thrown at libs/sdk-py/langgraph_sdk/_shared/utilities.py:76 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"38031739e551638e373fb553453256c23feeb41f","analyzedAt":"2026-08-26T18:02:49.312Z","schemaVersion":2},"datasetVersion":"2026-08-26T21:11:00.512Z"}