{"record":{"id":"036c54ba6a93bea0","repo":"PrefectHQ/fastmcp","slug":"elicitation-schema-field-prop-name-is-an-array-036c54","errorCode":null,"errorMessage":"Elicitation schema field '{prop_name}' is an array, but arrays are only allowed when items are enums (for multi-select). Only enum arrays are supported in elicitation schemas.","messagePattern":"Elicitation schema field '(.+?)' is an array, but arrays are only allowed when items are enums \\(for multi-select\\)\\. Only enum arrays are supported in elicitation schemas\\.","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"fastmcp_slim/fastmcp/server/elicitation.py","lineNumber":499,"sourceCode":"                raise TypeError(\n                    f\"Elicitation schema field '{prop_name}' is an array of objects, but arrays of objects are not allowed. \"\n                    \"Elicitation schemas must be flat objects with primitive properties only.\"\n                )\n\n            # Allow arrays with enum patterns (for multi-select)\n            if \"enum\" in items_schema:\n                continue  # Allowed: {\"type\": \"array\", \"items\": {\"enum\": [...]}}\n\n            # Allow arrays with oneOf/anyOf const patterns (SEP-1330)\n            if \"oneOf\" in items_schema or \"anyOf\" in items_schema:\n                union_schemas = items_schema.get(\"oneOf\", []) + items_schema.get(\n                    \"anyOf\", []\n                )\n                if union_schemas and all(\"const\" in s for s in union_schemas):\n                    continue  # Allowed: {\"type\": \"array\", \"items\": {\"anyOf\": [{\"const\": ...}, ...]}}\n\n            # Reject other array types (e.g., arrays of primitives without enum pattern)\n            raise TypeError(\n                f\"Elicitation schema field '{prop_name}' is an array, but arrays are only allowed \"\n                \"when items are enums (for multi-select). Only enum arrays are supported in elicitation schemas.\"\n            )\n\n        # Check for nested objects (not allowed)\n        if prop_type == \"object\":\n            raise TypeError(\n                f\"Elicitation schema field '{prop_name}' is an object, but nested objects are not allowed. \"\n                \"Elicitation schemas must be flat objects with primitive properties only.\"\n            )\n\n        # Check if it's a primitive type\n        if prop_type not in ALLOWED_TYPES:\n            raise TypeError(\n                f\"Elicitation schema field '{prop_name}' has type '{prop_type}' which is not \"\n                f\"a primitive type. Only {ALLOWED_TYPES} are allowed in elicitation schemas.\"\n            )\n","sourceCodeStart":481,"sourceCodeEnd":517,"githubUrl":"https://github.com/PrefectHQ/fastmcp/blob/1f021142978e0861cd910c8df4e8074bc7cf3978/fastmcp_slim/fastmcp/server/elicitation.py#L481-L517","documentation":"Beyond arrays of objects, elicitation arrays must follow the enum multi-select pattern: items with 'enum', or anyOf/oneOf branches that are all const/enum values. Any other array (e.g. list[int], list[str] of free-form strings) is rejected with this error.","triggerScenarios":"A response type like list[int], list[str], or list[float] that isn't a list[Enum]/list[Literal] — validated via get_elicitation_schema.","commonSituations":"Asking the user for a list of numbers or free-form tags; assuming list[str] is a multi-select (it must be Literal/Enum values); migrating from a generic JSON-form tool to elicitation.","solutions":["Change the field to list[Literal[...]] or list[SomeEnum] so items are enum-like","If free-form strings are needed, use a single string field with a separator, or multiple named primitive fields","Collect arbitrary lists via a tool call instead of elicitation"],"exampleFix":"// before\nclass Prefs(BaseModel):\n    scores: list[int]\n// after\nclass Prefs(BaseModel):\n    tier: list[Literal[\"basic\", \"pro\"]]  # enum multi-select","handlingStrategy":"validation","validationCode":"def check_enum_array(schema: dict) -> None:\n    for prop in schema.get(\"properties\", {}).values():\n        if prop.get(\"type\") != \"array\":\n            continue\n        items = prop.get(\"items\", {})\n        if \"enum\" in items:\n            continue\n        branches = items.get(\"anyOf\") or items.get(\"oneOf\") or []\n        if branches and all(\"const\" in b for b in branches):\n            continue\n        raise TypeError(\"arrays in elicitation must have enum/const items (multi-select only)\")","typeGuard":"def is_enum_array(prop_schema: dict) -> bool:\n    if not isinstance(prop_schema, dict) or prop_schema.get(\"type\") != \"array\":\n        return False\n    items = prop_schema.get(\"items\", {})\n    if \"enum\" in items:\n        return True\n    branches = items.get(\"anyOf\") or items.get(\"oneOf\") or []\n    return bool(branches) and all(\"const\" in b for b in branches)","tryCatchPattern":"try:\n    schema = get_elicitation_schema(response_type)\nexcept TypeError as e:\n    if \"arrays are only allowed\" in str(e):\n        logger.error(\"use list[Literal[...]] or list[Enum] for multi-select fields\")\n        return None\n    raise","preventionTips":["Use list[Literal[\"a\",\"b\"]] or list[MyEnum] — not list[str]/list[int] — for multi-select","Free-form string lists are not supported; use a delimited string field or multiple fields","Collect arbitrary lists with a tool call, not elicitation","Lint response models for non-enum list fields before deployment"],"tags":["elicitation","json-schema","arrays","fastmcp"],"backgroundTag":"schema-validation-failed","analyzedSha":"1f021142978e0861cd910c8df4e8074bc7cf3978","analyzedAt":"2026-08-29T14:31:16.082Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}