{"id":"881ab16693db9261","repo":"pydantic/pydantic","slug":"cannot-specify-multiple-annotated-field-s-for","errorCode":null,"errorMessage":"cannot specify multiple `Annotated` `Field`s for {field_name!r}","messagePattern":"cannot specify multiple `Annotated` `Field`s for (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"pydantic/v1/fields.py","lineNumber":461,"sourceCode":"        \"\"\"\n        Get a FieldInfo from a root typing.Annotated annotation, value, or config default.\n\n        The FieldInfo may be set in typing.Annotated or the value, but not both. If neither contain\n        a FieldInfo, a new one will be created using the config.\n\n        :param field_name: name of the field for use in error messages\n        :param annotation: a type hint such as `str` or `Annotated[str, Field(..., min_length=5)]`\n        :param value: the field's assigned value\n        :param config: the model's config object\n        :return: the FieldInfo contained in the `annotation`, the value, or a new one from the config.\n        \"\"\"\n        field_info_from_config = config.get_field_info(field_name)\n\n        field_info = None\n        if get_origin(annotation) is Annotated:\n            field_infos = [arg for arg in get_args(annotation)[1:] if isinstance(arg, FieldInfo)]\n            if len(field_infos) > 1:\n                raise ValueError(f'cannot specify multiple `Annotated` `Field`s for {field_name!r}')\n            field_info = next(iter(field_infos), None)\n            if field_info is not None:\n                field_info = copy.copy(field_info)\n                field_info.update_from_config(field_info_from_config)\n                if field_info.default not in (Undefined, Required):\n                    raise ValueError(f'`Field` default cannot be set in `Annotated` for {field_name!r}')\n                if value is not Undefined and value is not Required:\n                    # check also `Required` because of `validate_arguments` that sets `...` as default value\n                    field_info.default = value\n\n        if isinstance(value, FieldInfo):\n            if field_info is not None:\n                raise ValueError(f'cannot specify `Annotated` and value `Field`s together for {field_name!r}')\n            field_info = value\n            field_info.update_from_config(field_info_from_config)\n        elif field_info is None:\n            field_info = FieldInfo(value, **field_info_from_config)\n        value = None if field_info.default_factory is not None else field_info.default","sourceCodeStart":443,"sourceCodeEnd":479,"githubUrl":"https://github.com/pydantic/pydantic/blob/2e5f0e2b4218de31709f1cf9c5bc61ea97a68835/pydantic/v1/fields.py#L443-L479","documentation":"Raised by ModelField._get_field_info when a single field's typing.Annotated annotation contains more than one FieldInfo metadata entry. pydantic v1 allows at most one Field inside Annotated[...] because multiple FieldInfos would have conflicting constraints; the check counts isinstance(arg, FieldInfo) across the metadata args.","triggerScenarios":"Writing Annotated[str, Field(min_length=1), Field(max_length=10)] — two FieldInfo objects in one Annotated. Triggered at model creation when the annotation is processed.","commonSituations":"Combining constraints from reusable Annotated type aliases by stacking Field(); refactoring that accidentally duplicates Field metadata.","solutions":["Merge the constraints into a single Field inside the Annotated: Annotated[str, Field(min_length=1, max_length=10)].","Move one set of constraints into the model's Config.fields if applicable."],"exampleFix":"// before\nname: Annotated[str, Field(min_length=1), Field(max_length=10)]\n\n# after\nname: Annotated[str, Field(min_length=1, max_length=10)]","handlingStrategy":"validation","validationCode":"from typing import get_args, get_origin, Annotated\nfrom pydantic.v1.fields import FieldInfo\n\ndef _check_single_annotated_field(annotation):\n    if get_origin(annotation) is Annotated:\n        infos = [a for a in get_args(annotation)[1:] if isinstance(a, FieldInfo)]\n        if len(infos) > 1:\n            raise ValueError('merge multiple Annotated Field() calls into one')","typeGuard":"from typing import get_args, get_origin, Annotated\nfrom pydantic.v1.fields import FieldInfo\n\ndef has_single_annotated_field(annotation) -> bool:\n    if get_origin(annotation) is not Annotated:\n        return True\n    return sum(1 for a in get_args(annotation)[1:] if isinstance(a, FieldInfo)) <= 1","tryCatchPattern":null,"preventionTips":["Keep a single Field(...) inside each Annotated annotation.","Use shared Annotated type aliases with one consolidated Field.","Review Annotated usage during model refactors."],"tags":["pydantic-v1","field","annotated","config"],"analyzedSha":"2e5f0e2b4218de31709f1cf9c5bc61ea97a68835","analyzedAt":"2026-08-04T19:54:21.281Z","schemaVersion":2}