microsoft/semantic-kernel · error · FunctionExecutionException

No valid server URL for operation {self.id}

Error message

No valid server URL for operation {self.id}

What it means

In `get_server_url`, if there are no server variables to resolve, the method falls back to `self.server_url`, then `api_host_url`. If none of these three sources provides a server URL, this FunctionExecutionException is raised. It means the operation has no usable server URL from any source.

Source

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

                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 += "/"

        return server_url_string  # Return the URL string directly

    def build_path(self, path_template: str, arguments: dict[str, Any]) -> str:
        """Build the path for the operation."""
        parameters = [p for p in self.parameters if p.location == RestApiParameterLocation.PATH]
        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}`."
                    )

View on GitHub (pinned to c028a0c7dc)

Solutions

  1. Pass a `server_url_override` when invoking the operation or configuring the runner.
  2. Ensure the OpenAPI spec includes a `servers` entry with a valid URL.
  3. Provide `api_host_url` to the OpenAPI runner/operation when loading a spec without server definitions.

Example fix

// before (spec has no servers, no override)
result = await api.call_op()
// after
result = await api.call_op(server_url_override="https://api.example.com/")
Defensive patterns

Strategy: validation

Validate before calling

def has_server_url(operation, server_url_override=None, api_host_url=None):
    if server_url_override:
        return True
    if getattr(operation, 'server_url', None):
        return True
    if api_host_url:
        return True
    if operation.servers:
        return True
    raise ValueError("No server URL available; pass server_url_override or api_host_url.")

Try / catch

try:
    result = await api.my_operation(**args)
except FunctionExecutionException as e:
    if "No valid server URL" in str(e):
        # pass server_url_override when invoking
        ...

Prevention

When it happens

Trigger: An operation has no server URL defined (no `servers` in the spec, no `server_url` attribute, no `server_url_override`, and no `api_host_url` passed to the runner). All server URL resolution paths are empty.

Common situations: Loading an OpenAPI spec that has no `servers` field and no `host`/`basePath` (older Swagger 2.0 style without host). Forgetting to pass `server_url_override` or `api_host_url` when the spec lacks server info. Plugin runner misconfiguration.

Related errors


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