{"id":"7168967341b90346","repo":"pydantic/pydantic","slug":"fields-of-type-origin-are-not-supported","errorCode":null,"errorMessage":"Fields of type \"{origin}\" are not supported.","messagePattern":"Fields of type \"(.+?)\" are not supported\\.","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"pydantic/v1/fields.py","lineNumber":753,"sourceCode":"            self.type_ = get_args(self.type_)[1]\n            self.shape = SHAPE_MAPPING\n        # Equality check as almost everything inherits form Iterable, including str\n        # check for Iterable and CollectionsIterable, as it could receive one even when declared with the other\n        elif origin in {Iterable, CollectionsIterable}:\n            self.type_ = get_args(self.type_)[0]\n            self.shape = SHAPE_ITERABLE\n            self.sub_fields = [self._create_sub_type(self.type_, f'{self.name}_type')]\n        elif issubclass(origin, Type):  # type: ignore\n            return\n        elif hasattr(origin, '__get_validators__') or self.model_config.arbitrary_types_allowed:\n            # Is a Pydantic-compatible generic that handles itself\n            # or we have arbitrary_types_allowed = True\n            self.shape = SHAPE_GENERIC\n            self.sub_fields = [self._create_sub_type(t, f'{self.name}_{i}') for i, t in enumerate(get_args(self.type_))]\n            self.type_ = origin\n            return\n        else:\n            raise TypeError(f'Fields of type \"{origin}\" are not supported.')\n\n        # type_ has been refined eg. as the type of a List and sub_fields needs to be populated\n        self.sub_fields = [self._create_sub_type(self.type_, '_' + self.name)]\n\n    def prepare_discriminated_union_sub_fields(self) -> None:\n        \"\"\"\n        Prepare the mapping <discriminator key> -> <ModelField> and update `sub_fields`\n        Note that this process can be aborted if a `ForwardRef` is encountered\n        \"\"\"\n        assert self.discriminator_key is not None\n\n        if self.type_.__class__ is DeferredType:\n            return\n\n        assert self.sub_fields is not None\n        sub_fields_mapping: Dict[str, 'ModelField'] = {}\n        all_aliases: Set[str] = set()\n","sourceCodeStart":735,"sourceCodeEnd":771,"githubUrl":"https://github.com/pydantic/pydantic/blob/2e5f0e2b4218de31709f1cf9c5bc61ea97a68835/pydantic/v1/fields.py#L735-L771","documentation":"Raised by ModelField._type_analysis as the final else branch when the field's type origin is a generic class that pydantic v1 does not recognize and arbitrary_types_allowed is False. Recognized origins include standard containers (list/tuple/set/dict/Iterable/Mapping/Deque/Counter/Type) and types exposing __get_validators__; anything else falls through to this error.","triggerScenarios":"Using a third-party or custom generic class as a field type that has no __get_validators__ method, without enabling arbitrary_types_allowed. Example: x: PathLibPath or x: SomeExternalGeneric[T] where the class is not a pydantic-compatible validator provider.","commonSituations":"Adding a pandas/numpy/attrs-typed field to a model; using a generic from a library that pydantic v1 has no built-in support for; upgrading pydantic where v2-only types are used against the v1 compatibility shim.","solutions":["Set arbitrary_types_allowed = True in the model Config so pydantic accepts the type without validation coercion.","Add a classmethod __get_validators__ to the custom type so pydantic can validate it.","Replace the unsupported type with a supported primitive or a pydantic-compatible wrapper."],"exampleFix":"// before\nclass M(BaseModel):\n    df: pandas.DataFrame  # raises: Fields of type \"pandas.DataFrame\" are not supported\n\n# after\nclass M(BaseModel):\n    class Config:\n        arbitrary_types_allowed = True\n    df: pandas.DataFrame","handlingStrategy":"validation","validationCode":"def _ensure_type_supported(origin, arbitrary_allowed):\n    supported = (list, tuple, set, frozenset, dict, type, ...)\n    if origin is not None and origin not in supported and not hasattr(origin, '__get_validators__'):\n        if not arbitrary_allowed:\n            raise TypeError(f'enable arbitrary_types_allowed or add __get_validators__ to {origin}')","typeGuard":"def type_is_supported_by_pydantic_v1(origin, arbitrary_allowed: bool) -> bool:\n    if origin is None:\n        return True\n    if hasattr(origin, '__get_validators__'):\n        return True\n    return bool(arbitrary_allowed)","tryCatchPattern":null,"preventionTips":["Set arbitrary_types_allowed = True when using third-party generic types.","Implement __get_validators__ on custom types for full pydantic integration.","Prefer native containers or pydantic-compatible types where possible."],"tags":["pydantic-v1","field","type","arbitrary-types"],"analyzedSha":"2e5f0e2b4218de31709f1cf9c5bc61ea97a68835","analyzedAt":"2026-08-04T19:54:21.281Z","schemaVersion":2}