{"record":{"id":"9aa024f51a2b1824","repo":"microsoft/semantic-kernel","slug":"schema-data-is-required-to-convert-the-kernel-func","errorCode":null,"errorMessage":"Schema data is required to convert the kernel function parameter type to bedrock function parameter type.","messagePattern":"Schema data is required to convert the kernel function parameter type to bedrock function parameter type\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/semantic_kernel/agents/bedrock/action_group_utils.py","lineNumber":71,"sourceCode":"    # Remove None values from the schema\n    return {key: value for key, value in schema.items() if value is not None}\n\n\n# These are the allowed parameter types in bedrock function.\n# https://docs.aws.amazon.com/bedrock/latest/APIReference/API_agent-runtime_ParameterDetail.html\nBEDROCK_FUNCTION_ALLOWED_PARAMETER_TYPES = {\n    \"string\",\n    \"number\",\n    \"integer\",\n    \"boolean\",\n    \"array\",\n}\n\n\ndef kernel_function_parameter_type_to_bedrock_function_parameter_type(schema_data: dict[str, Any] | None) -> str:\n    \"\"\"Convert the kernel function parameter type to bedrock function parameter type.\"\"\"\n    if schema_data is None:\n        raise ValueError(\n            \"Schema data is required to convert the kernel function parameter type to bedrock function parameter type.\"\n        )\n\n    type_ = schema_data.get(\"type\")\n    if type_ is None:\n        raise ValueError(\n            \"Type is required to convert the kernel function parameter type to bedrock function parameter type.\"\n        )\n\n    if type_ not in BEDROCK_FUNCTION_ALLOWED_PARAMETER_TYPES:\n        raise ValueError(\n            f\"Type {type_} is not allowed in bedrock function parameter type. \"\n            f\"Allowed types are {BEDROCK_FUNCTION_ALLOWED_PARAMETER_TYPES}.\"\n        )\n\n    return type_\n\n","sourceCodeStart":53,"sourceCodeEnd":89,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/python/semantic_kernel/agents/bedrock/action_group_utils.py#L53-L89","documentation":"Raised by kernel_function_parameter_type_to_bedrock_function_parameter_type when schema_data is None. Bedrock requires every function parameter to declare a JSON-schema type, and the converter derives it from schema_data, so a None schema cannot be mapped. Thrown as a plain ValueError during Bedrock action-group schema generation.","triggerScenarios":"Registering a kernel function whose parameter has no schema_data (e.g. a parameter with no type annotation or a None schema) and then exposing it to a Bedrock agent; a custom KernelParameterMetadata built without schema_data; a function with a complex/unhandled annotation that produced None schema.","commonSituations":"Using Python functions with no type hints as kernel functions for a Bedrock agent; a parameter typed as a custom class that the schema generator could not map; dynamic function registration that skipped schema population.","solutions":["Add a JSON-schema-compatible type annotation (str, int, float, bool, list) to the kernel function parameter so schema_data is populated.","If building KernelParameterMetadata manually, supply schema_data={'type':'string'} (or the appropriate type).","Filter out parameters without schemas before exposing the function to Bedrock, or provide default schemas."],"exampleFix":"// before\n@kernel_function\ndef search(query): ...  // no annotation -> schema_data None\n// after\n@kernel_function\nasync def search(self, query: str) -> str: ...  // str -> schema_data {'type':'string'}","handlingStrategy":"validation","validationCode":"def validate_bedrock_params(function_metadata):\n    for p in function_metadata.parameters:\n        if p.schema_data is None:\n            raise ValueError(f\"parameter '{p.name}' has no schema_data; add a type annotation\")\n    return function_metadata","typeGuard":"def param_has_schema(param) -> bool:\n    return getattr(param, 'schema_data', None) is not None","tryCatchPattern":"from semantic_kernel.agents.bedrock.action_group_utils import kernel_function_to_bedrock_function_schema\ntry:\n    schema = kernel_function_to_bedrock_function_schema(cfg)\nexcept ValueError as e:\n    if 'Schema data is required' in str(e):\n        log.error('A kernel function parameter lacks a type annotation/schema')\n    raise","preventionTips":["Annotate all kernel function parameters with primitive types (str/int/float/bool/list).","When building KernelParameterMetadata manually, always set schema_data.","Filter or default parameters that have no schema before Bedrock conversion."],"tags":["bedrock","function-schema","type-annotation","configuration","agent-initialization"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}