microsoft/semantic-kernel · error · FunctionExecutionException
No variable found in context to use as an argument for the `
Error message
No variable found in context to use as an argument for the `{parameter.name}` parameter of the `{plugin_name}.{operation.id}` REST function. What it means
When the generated REST function is invoked, each parameter is resolved from `kwargs` by `alternative_name` then `name`. If a parameter `is_required` and neither key yields a non-None value, `FunctionExecutionException` is raised naming the parameter and the `plugin.operation`. Optional parameters with no argument are simply skipped.
Source
Thrown at python/semantic_kernel/connectors/openapi_plugin/openapi_manager.py:152
) -> str:
try:
kernel_arguments = KernelArguments()
for parameter in rest_operation_params:
if parameter.alternative_name and parameter.alternative_name in kwargs:
value = kwargs[parameter.alternative_name]
if value is not None:
kernel_arguments[parameter.name] = value
continue
if parameter.name in kwargs:
value = kwargs[parameter.name]
if value is not None:
kernel_arguments[parameter.name] = value
continue
if parameter.is_required:
raise FunctionExecutionException(
f"No variable found in context to use as an argument for the "
f"`{parameter.name}` parameter of the `{plugin_name}.{operation.id}` REST function."
)
options = RestApiRunOptions(
server_url_override=(
execution_parameters.server_url_override
if execution_parameters and execution_parameters.server_url_override is not None
else None
),
api_host_url=Uri(document_uri).get_left_part() if document_uri is not None else None,
timeout=execution_parameters.timeout
if execution_parameters and execution_parameters.timeout is not None
else None,
)
return await runner.run_operation(operation, kernel_arguments, options)
except Exception as e:View on GitHub (pinned to c028a0c7dc)
Solutions
- Pass the missing required argument under the parameter's `alternative_name` (preferred) or `name`.
- Inspect the function's `parameters` metadata to see the exact expected argument names.
- Make the parameter optional in the spec (or supply a `default`) if it can be omitted.
- Provide a wrapper that pre-fills defaults for required args before invoking.
Example fix
# before result = await kernel.invoke(pet_fn, KernelArguments()) # raises 1487 (missing 'petId') # after from semantic_kernel.functions import KernelArguments result = await kernel.invoke(pet_fn, KernelArguments(petId=42))
Defensive patterns
Strategy: validation
Validate before calling
def required_args_supplied(fn, kwargs) -> None:
missing = [
(p.alternative_name or p.name)
for p in fn.parameters
if p.is_required and kwargs.get(p.alternative_name or p.name) is None
]
if missing:
raise ValueError(f"Missing required arguments: {missing}")
required_args_supplied(rest_fn, kwargs)
await kernel.invoke(rest_fn, KernelArguments(**kwargs)) Type guard
def is_required_param(p) -> bool:
return bool(getattr(p, "is_required", False)) Try / catch
from semantic_kernel.exceptions import FunctionExecutionException
try:
result = await kernel.invoke(rest_fn, KernelArguments(**kwargs))
except FunctionExecutionException as e:
if "No variable found in context" in str(e):
# extract expected param, fill it, retry once
raise
raise Prevention
- Inspect `fn.parameters` to learn exact required argument names.
- Pre-fill required defaults in your wrapper before invoking.
- Pass arguments under the parameter's `alternative_name` when set.
- Add a pre-flight check that all required args are non-None.
When it happens
Trigger: Invoking the kernel function (e.g. via `kernel.invoke`) without passing a required argument; passing it under a different name than `alternative_name`/`name`; passing `None` explicitly for a required parameter; argument-name mismatch after a spec rename.
Common situations: Prompt/function-calling omits a required slot; the caller uses the OpenAPI parameter name while the kernel expects the `alternative_name` (or vice versa); a refactor renamed a parameter but callers were not updated; required path/query params not surfaced by the model.
Related errors
- No argument is found for the '{property_metadata.name}' payl
- The task must be a ChatMessageContent object.
- This `RestApiParameter` instance is frozen and cannot be mod
- This `RestApiPayload` instance is frozen and cannot be modif
- This instance is frozen and cannot be modified.
AI-assisted analysis of microsoft/semantic-kernel@c028a0c7dc (2026-08-13).
Data as JSON: /api/errors/31d1add99228248f.
Report an issue: GitHub.