{"record":{"id":"867f64f7c8ef7c6c","repo":"microsoft/autogen","slug":"unsupported-or-missing-type-for-field-key-in","errorCode":null,"errorMessage":"Unsupported or missing type for field `{key}` in `{model_name}`","messagePattern":"Unsupported or missing type for field `(.+?)` in `(.+?)`","errorType":"exception","errorClass":"UnsupportedKeywordError","httpStatus":null,"severity":"error","filePath":"python/packages/autogen-core/src/autogen_core/utils/_json_to_pydantic.py","lineNumber":347,"sourceCode":"                field_type = Literal[tuple(value[\"enum\"])]\n            elif \"allOf\" in value:\n                merged = {\"type\": \"object\", \"properties\": {}, \"required\": []}\n                for s in value[\"allOf\"]:\n                    part = self._resolve_ref(s[\"$ref\"], root_schema) if \"$ref\" in s else s\n                    merged[\"properties\"].update(part.get(\"properties\", {}))\n                    merged[\"required\"].extend(part.get(\"required\", []))\n                for k, v in value.items():\n                    if k not in {\"allOf\", \"properties\", \"required\"}:\n                        merged[k] = v\n                merged[\"required\"] = list(set(merged[\"required\"]))\n                field_type = self._json_schema_to_model(merged, f\"{model_name}_{key}\", root_schema)\n            elif value.get(\"type\") == \"object\" and \"properties\" in value:\n                field_type = self._json_schema_to_model(value, f\"{model_name}_{key}\", root_schema)\n            else:\n                field_type = self._extract_field_type(key, value, model_name, root_schema)\n\n            if field_type is None:\n                raise UnsupportedKeywordError(f\"Unsupported or missing type for field `{key}` in `{model_name}`\")\n\n            default_value = value.get(\"default\")\n            is_required = key in required_fields\n\n            if not is_required and default_value is None:\n                field_type = Optional[field_type]\n\n            field_args = {\n                \"default\": default_value if not is_required else ...,\n            }\n            if \"title\" in value:\n                field_args[\"title\"] = value[\"title\"]\n            if \"description\" in value:\n                field_args[\"description\"] = value[\"description\"]\n\n            fields[key] = (\n                field_type,\n                _make_field(","sourceCodeStart":329,"sourceCodeEnd":365,"githubUrl":"https://github.com/microsoft/autogen/blob/027ecf0a379bcc1d09956d46d12d44a3ad9cee14/python/packages/autogen-core/src/autogen_core/utils/_json_to_pydantic.py#L329-L365","documentation":"Thrown by PydanticModelBuilder (json_schema_to_pydantic) when a JSON Schema property's type cannot be mapped to any Python/Pydantic type. _json_schema_to_model first tries $ref/anyOf/oneOf/enum/allOf/object-with-properties, then falls back to _extract_field_type; if that also returns None (e.g. the property has no 'type' key and no other recognized keyword, or a type not in TYPE_MAPPING such as 'null' as the sole type), UnsupportedKeywordError is raised. It means the schema you supplied (typically from a structured-output tool or an OpenAPI/tool definition) uses a construct this converter does not support.","triggerScenarios":"Calling json_schema_to_pydantic (directly or via a tool/agent that generates Pydantic models from JSON Schema) with a schema whose property declares: no 'type' at all (e.g. only 'description'), an unsupported primitive type like \"type\": \"null\", a type string not in TYPE_MAPPING, or an object without 'properties' that also has no matching branch in _extract_field_type.","commonSituations":"Hand-written or LLM-generated JSON Schemas that omit 'type'; OpenAPI 3.1 schemas using 'null' as a standalone type; schemas using advanced JSON Schema 2020-12 keywords this converter ignores; feeding an arbitrary third-party API schema into a structured-output pipeline.","solutions":["Find the offending field: the message names the field `key` and model `model_name`; inspect that property in your schema.","Add an explicit, supported \"type\" (string, integer, number, boolean, array, object) to the property, or replace the construct with anyOf/oneOf/$ref/enum which the converter handles.","Replace a bare \"type\": \"null\" with an anyOf including null / a nullable sibling, or just make the field optional.","If the schema comes from a tool definition, regenerate it (e.g. from a typed function via FunctionTool) instead of authoring it by hand.","As a last resort, use a plain Pydantic model you define yourself instead of converting the schema."],"exampleFix":"// before\n{\"type\":\"object\",\"properties\":{\"meta\":{\"description\":\"opaque blob\"}}}\n// after\n{\"type\":\"object\",\"properties\":{\"meta\":{\"type\":\"string\",\"description\":\"opaque blob\"}}}","handlingStrategy":"validation","validationCode":"SUPPORTED = {\"string\",\"integer\",\"number\",\"boolean\",\"array\",\"object\"}\ndef schema_fields_supported(schema):\n    for key, prop in schema.get(\"properties\", {}).items():\n        has_structural = any(k in prop for k in (\"$ref\",\"anyOf\",\"oneOf\",\"enum\",\"allOf\"))\n        if not has_structural and prop.get(\"type\") not in SUPPORTED:\n            return False, key\n    return True, None","typeGuard":"def is_supported_property(prop: dict) -> bool:\n    return any(k in prop for k in (\"$ref\",\"anyOf\",\"oneOf\",\"enum\",\"allOf\")) or prop.get(\"type\") in {\"string\",\"integer\",\"number\",\"boolean\",\"array\",\"object\"}","tryCatchPattern":"try:\n    model = json_schema_to_pydantic(schema)\nexcept UnsupportedKeywordError as e:\n    # message names field and model; fix schema or fall back to a hand-written model\n    ...","preventionTips":["Generate schemas from typed functions (FunctionTool) rather than authoring JSON Schema by hand.","Run a schema lint pass (every property has a known 'type' or $ref/anyOf/enum) before conversion.","Avoid OpenAPI 3.1 'null' standalone types and JSON Schema 2020-12-only keywords."],"tags":["pydantic","json-schema","validation","autogen-core"],"backgroundTag":null,"analyzedSha":"027ecf0a379bcc1d09956d46d12d44a3ad9cee14","analyzedAt":"2026-08-15T03:38:00.719Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}