microsoft/semantic-kernel · error · FunctionExecutionException

No argument provided for the '{variable_name}' server variab

Error message

No argument provided for the '{variable_name}' server variable of the operation '{self.id}'.

What it means

When resolving the server URL template, `get_server_url` iterates over declared server variables. For each variable, it uses an explicit argument if provided, falls back to the spec's default, and if neither exists raises this FunctionExecutionException. It indicates a required server URL variable has no value and no default in the OpenAPI spec.

Source

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

            server_url_string = server_url_override
        elif self.servers and len(self.servers) > 0:
            # Use the first server by default
            server = self.servers[0]
            server_url_string = server["url"] if isinstance(server, dict) else server
            server_variables = server.get("variables", {}) if isinstance(server, dict) else {}

            # Substitute server variables if available
            for variable_name, variable_def in server_variables.items():
                argument_name = variable_def.get("argument_name", variable_name)
                allowed_values = variable_def.get("enum")
                if argument_name in arguments:
                    value = str(arguments[argument_name])
                elif "default" in variable_def and variable_def["default"] is not None:
                    # Use the default value if no argument is provided
                    value = str(variable_def["default"])
                else:
                    # Raise an exception if no value is available
                    raise FunctionExecutionException(
                        f"No argument provided for the '{variable_name}' server variable of the operation '{self.id}'."
                    )
                if allowed_values is not None and value not in allowed_values:
                    raise FunctionExecutionException(
                        f"Value '{value}' for server variable '{variable_name}' is not one of the allowed values."
                    )
                server_url_string = server_url_string.replace(f"{{{variable_name}}}", quote(value, safe=""))
        elif self.server_url:
            server_url_string = self.server_url
        elif api_host_url is not None:
            server_url_string = api_host_url
        else:
            raise FunctionExecutionException(f"No valid server URL for operation {self.id}")

        # Ensure the base URL ends with a trailing slash
        if not server_url_string.endswith("/"):
            server_url_string += "/"

View on GitHub (pinned to c028a0c7dc)

Solutions

  1. Provide an argument for the server variable using its `argument_name` (or the variable name if no `argument_name` is defined).
  2. Add a `default` value for the variable in the OpenAPI spec.
  3. Use a `server_url_override` to bypass server variable resolution entirely.

Example fix

// before (missing 'region' server variable)
await api.call_op()
// after
await api.call_op(region="us-east-1")
Defensive patterns

Strategy: validation

Validate before calling

def validate_server_variables(operation, arguments: dict):
    for server in (operation.servers or []):
        for var_name, var_def in (server.get('variables') or {}).items():
            arg_name = var_def.get('argument_name', var_name)
            if arg_name not in arguments and var_def.get('default') is None:
                raise ValueError(f"No value for server variable '{var_name}'; provide '{arg_name}' or add a default.")

Try / catch

try:
    result = await api.my_operation(**args)
except FunctionExecutionException as e:
    if "server variable" in str(e) and "No argument" in str(e):
        # provide the missing server variable argument
        ...

Prevention

When it happens

Trigger: The OpenAPI spec defines a server URL with templated variables (e.g. `https://{host}.example.com/`) but a variable has no default and no argument is supplied at call time. The arguments dict does not contain the variable's `argument_name`.

Common situations: Calling an operation whose server URL has variables without providing all variable values. The spec omits defaults for server variables. The argument name for the variable differs from what the caller passes (the spec's `argument_name` extension is used if present).

Related errors


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