{"record":{"id":"125e0a6bad8249f8","repo":"langchain-ai/langgraph","slug":"expected-a-type-got-type-obj","errorCode":null,"errorMessage":"Expected a type, got {type(obj)}. ","messagePattern":"Expected a type, got (.+?)\\. ","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"libs/langgraph/langgraph/_internal/_fields.py","lineNumber":213,"sourceCode":"\ndef get_cached_annotated_keys(obj: type[Any]) -> tuple[str, ...]:\n    \"\"\"Return cached annotated keys for a Python class.\"\"\"\n    if obj in ANNOTATED_KEYS_CACHE:\n        return ANNOTATED_KEYS_CACHE[obj]\n    if isinstance(obj, type):\n        keys: list[str] = []\n        for base in reversed(obj.__mro__):\n            ann = base.__dict__.get(\"__annotations__\")\n            # In Python 3.14+, Pydantic models use descriptors for __annotations__\n            # so we need to fall back to getattr if __dict__.get returns None\n            if ann is None:\n                ann = getattr(base, \"__annotations__\", None)\n            if ann is None or isinstance(ann, types.GetSetDescriptorType):\n                continue\n            keys.extend(ann.keys())\n        return ANNOTATED_KEYS_CACHE.setdefault(obj, tuple(keys))\n    else:\n        raise TypeError(f\"Expected a type, got {type(obj)}. \")\n","sourceCodeStart":195,"sourceCodeEnd":214,"githubUrl":"https://github.com/langchain-ai/langgraph/blob/38031739e551638e373fb553453256c23feeb41f/libs/langgraph/langgraph/_internal/_fields.py#L195-L214","documentation":"get_cached_annotated_keys asserts its argument is a class (it inspects __mro__ and __annotations__); a non-type instance was passed, so a TypeError naming the offending type is raised before annotation caching proceeds.","triggerScenarios":"Thrown at libs/langgraph/langgraph/_internal/_fields.py:213 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass the class itself (e.g. MyState), not an instance, to the annotated-keys helper.","Check the calling code for accidental instance-vs-class confusion."],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"38031739e551638e373fb553453256c23feeb41f","analyzedAt":"2026-08-26T18:02:49.312Z","contentChangedAt":"2026-08-26T18:02:49.312Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}