{"record":{"id":"4cce76d2a578e432","repo":"langchain-ai/langgraph","slug":"expected-a-pydantic-model-got-type-model","errorCode":null,"errorMessage":"Expected a Pydantic model. Got {type(model)}","messagePattern":"Expected a Pydantic model\\. Got (.+?)","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"libs/langgraph/langgraph/_internal/_pydantic.py","lineNumber":51,"sourceCode":"@overload\ndef get_fields(model: type[BaseModel]) -> dict[str, FieldInfo]: ...\n\n\n@overload\ndef get_fields(model: BaseModel) -> dict[str, FieldInfo]: ...\n\n\ndef get_fields(\n    model: type[BaseModel] | BaseModel,\n) -> dict[str, FieldInfo]:\n    \"\"\"Get the field names of a Pydantic model.\"\"\"\n    if hasattr(model, \"model_fields\"):\n        return model.model_fields\n\n    if hasattr(model, \"__fields__\"):\n        return model.__fields__\n    msg = f\"Expected a Pydantic model. Got {type(model)}\"\n    raise TypeError(msg)\n\n\n_SchemaConfig = ConfigDict(\n    arbitrary_types_allowed=True, frozen=True, protected_namespaces=()\n)\n\nNO_DEFAULT = object()\n\n\ndef _create_root_model(\n    name: str,\n    type_: Any,\n    module_name: str | None = None,\n    default_: object = NO_DEFAULT,\n) -> type[BaseModel]:\n    \"\"\"Create a base class.\"\"\"\n\n    def schema(","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/langchain-ai/langgraph/blob/38031739e551638e373fb553453256c23feeb41f/libs/langgraph/langgraph/_internal/_pydantic.py#L33-L69","documentation":"get_fields introspects Pydantic models via model_fields (v2) with a __fields__ (v1) fallback; if the object has neither attribute it is not a Pydantic model, so TypeError is raised naming the received type.","triggerScenarios":"Thrown at libs/langgraph/langgraph/_internal/_pydantic.py:51 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass a Pydantic BaseModel class or instance.","Verify the object is not a dataclass/TypedDict/schema-dict masquerading as a model."],"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"}