microsoft/semantic-kernel · error · ValueError

Type is required to convert the kernel function parameter ty

Error message

Type is required to convert the kernel function parameter type to bedrock function parameter type.

What it means

Raised by the same Bedrock type converter when schema_data is present but has no 'type' key. The converter only knows how to map an explicit JSON-schema type, so a schema without 'type' (e.g. one containing only a description or $ref) cannot be translated. Thrown as a plain ValueError.

Source

Thrown at python/semantic_kernel/agents/bedrock/action_group_utils.py:77

BEDROCK_FUNCTION_ALLOWED_PARAMETER_TYPES = {
    "string",
    "number",
    "integer",
    "boolean",
    "array",
}


def kernel_function_parameter_type_to_bedrock_function_parameter_type(schema_data: dict[str, Any] | None) -> str:
    """Convert the kernel function parameter type to bedrock function parameter type."""
    if schema_data is None:
        raise ValueError(
            "Schema data is required to convert the kernel function parameter type to bedrock function parameter type."
        )

    type_ = schema_data.get("type")
    if type_ is None:
        raise ValueError(
            "Type is required to convert the kernel function parameter type to bedrock function parameter type."
        )

    if type_ not in BEDROCK_FUNCTION_ALLOWED_PARAMETER_TYPES:
        raise ValueError(
            f"Type {type_} is not allowed in bedrock function parameter type. "
            f"Allowed types are {BEDROCK_FUNCTION_ALLOWED_PARAMETER_TYPES}."
        )

    return type_


def parse_return_control_payload(return_control_payload: dict[str, Any]) -> list[FunctionCallContent]:
    """Parse the return control payload to a list of function call contents for the kernel."""
    return [
        FunctionCallContent(
            id=return_control_payload["invocationId"],
            name=invocation_input["functionInvocationInput"]["function"],

View on GitHub (pinned to c028a0c7dc)

Solutions

  1. Ensure schema_data contains a 'type' key with one of: string, number, integer, boolean, array.
  2. When building schema_data manually, always include type (e.g. {'type':'string','description':'...'}).
  3. Use a primitive annotation that yields a typed schema, or map object/enum parameters to 'array'/'string' explicitly.

Example fix

// before
param = KernelParameterMetadata(name='q', schema_data={'description':'query'})  // no type
// after
param = KernelParameterMetadata(
    name='q', schema_data={'type':'string','description':'query'},
)
Defensive patterns

Strategy: validation

Validate before calling

ALLOWED = {'string','number','integer','boolean','array'}
def validate_bedrock_param_types(function_metadata):
    for p in function_metadata.parameters:
        sd = p.schema_data or {}
        t = sd.get('type')
        if not t:
            raise ValueError(f"parameter '{p.name}' schema_data lacks a 'type'")
        if t not in ALLOWED:
            raise ValueError(f"parameter '{p.name}' type '{t}' not allowed for Bedrock")
    return function_metadata

Type guard

ALLOWED = {'string','number','integer','boolean','array'}
def param_has_valid_type(param) -> bool:
    sd = getattr(param, 'schema_data', None) or {}
    return sd.get('type') in ALLOWED

Try / catch

try:
    schema = kernel_function_to_bedrock_function_schema(cfg)
except ValueError as e:
    if 'Type is required' in str(e):
        log.error('A parameter schema_data dict is missing the type key')
    raise

Prevention

When it happens

Trigger: A KernelParameterMetadata whose schema_data dict lacks a 'type' field (e.g. {'description': '...'} only); a schema generated from an annotation the generator represented without a top-level type; a manually-built schema missing the type key.

Common situations: Parameters described only by description/description metadata; custom schema_data set at registration without the type field; an enum or object annotation that the schema generator emitted as {'enum':[...]} without a type.

Related errors


AI-assisted analysis of microsoft/semantic-kernel@c028a0c7dc (2026-08-13). Data as JSON: /api/errors/63f5849e5105873d. Report an issue: GitHub.