microsoft/semantic-kernel · error · FunctionExecutionException

No argument is provided for the `{parameter.name}` required

Error message

No argument is provided for the `{parameter.name}` required parameter of the operation - `{self.id}`.

What it means

When building HTTP headers for a REST API operation call, `build_headers` iterates over parameters located in the HEADER and checks that each required one has a corresponding argument. This FunctionExecutionException is raised when a required header parameter has no value supplied in the arguments dict. Optional header parameters without arguments are silently skipped.

Source

Thrown at python/semantic_kernel/connectors/openapi_plugin/models/rest_api_operation.py:212

    def url_join(self, base_url: str, path: str):
        """Join a base URL and a path, correcting for any missing slashes."""
        parsed_base = urlparse(base_url)
        base_path = parsed_base.path + "/" if not parsed_base.path.endswith("/") else parsed_base.path
        full_path = urljoin(base_path, path.lstrip("/"))
        return urlunparse(parsed_base._replace(path=full_path))

    def build_headers(self, arguments: dict[str, Any]) -> dict[str, str]:
        """Build the headers for the operation."""
        headers = {}

        parameters = [p for p in self.parameters if p.location == RestApiParameterLocation.HEADER]

        for parameter in parameters:
            argument = arguments.get(parameter.name)

            if argument is None:
                if parameter.is_required:
                    raise FunctionExecutionException(
                        f"No argument is provided for the `{parameter.name}` "
                        f"required parameter of the operation - `{self.id}`."
                    )
                continue

            headers[parameter.name] = str(argument)

        return headers

    def build_operation_url(self, arguments, server_url_override=None, api_host_url=None):
        """Build the URL for the operation."""
        server_url = self.get_server_url(server_url_override, api_host_url, arguments)
        path = self.build_path(self.path, arguments)
        try:
            request_url = urljoin(server_url, path.lstrip("/"))
        except Exception as e:
            raise FunctionExecutionException(f"Error building the URL for the operation {self.id}: {e!s}") from e
        self._ensure_request_target_matches_server(server_url, request_url)

View on GitHub (pinned to c028a0c7dc)

Solutions

  1. Provide a value for every required header parameter named in the error message when calling the operation.
  2. Review the OpenAPI spec to identify all required header parameters and ensure each is supplied.
  3. If the parameter should be optional, correct the OpenAPI spec's `required` field.

Example fix

// before
result = await my_api.get_items()  # missing required 'X-API-Key' header
// after
result = await my_api.get_items(x_api_key="my-secret-key")
Defensive patterns

Strategy: validation

Validate before calling

def validate_required_headers(operation, arguments: dict):
    required = [p.name for p in operation.parameters
                if p.location == RestApiParameterLocation.HEADER and p.is_required]
    missing = [p for p in required if arguments.get(p) is None]
    if missing:
        raise ValueError(f"Missing required header parameters: {missing}")

Try / catch

try:
    result = await api.my_operation(**args)
except FunctionExecutionException as e:
    if "required parameter" in str(e) and "header" in str(e).lower():
        # supply the missing header argument
        ...

Prevention

When it happens

Trigger: Invoking an OpenAPI operation function without providing a value for a parameter declared as `required: true` in the `header` location. The function arguments dict is missing the key matching the parameter name.

Common situations: Calling a generated plugin function and forgetting to pass a required header (e.g. Authorization, X-API-Key). Parameter name in the spec differs from what the caller supplies. The OpenAPI spec marks a header as required but the caller assumes it is optional.

Related errors


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