microsoft/semantic-kernel · error · FunctionExecutionException

The operation path resolves to '{request.scheme}://{request.

Error message

The operation path resolves to '{request.scheme}://{request.netloc}', which does not match the configured server '{server.scheme}://{server.netloc}'.

What it means

A security-oriented check: after joining the server URL and operation path, `_ensure_request_target_matches_server` verifies the resulting request URL has the same scheme, host, and port as the configured server. If they differ, this FunctionExecutionException is raised. This prevents an operation path or server-variable substitution from silently redirecting a credential-bearing request to an unintended host (SSRF protection).

Source

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

        A selected operation path must resolve to a request on the same scheme, host, and port and
        within the server's base path. Otherwise an absolute or authority-changing operation path
        (for example "https://another-host/admin") could redirect a credential-bearing request to an
        unintended target even though it carries no dot-segment. This complements
        `_validate_path_segments` so operation selection, path validation, and request construction
        share one canonical target.
        """
        server = urlparse(server_url)
        request = urlparse(request_url)

        if (request.scheme, request.username, request.password, request.hostname, request.port) != (
            server.scheme,
            server.username,
            server.password,
            server.hostname,
            server.port,
        ):
            raise FunctionExecutionException(
                f"The operation path resolves to '{request.scheme}://{request.netloc}', which does not match "
                f"the configured server '{server.scheme}://{server.netloc}'."
            )

        # get_server_url guarantees a trailing slash, so the server base path always ends with "/".
        base_path = server.path
        if request.path != base_path.rstrip("/") and not request.path.startswith(base_path):
            raise FunctionExecutionException(
                f"The operation path resolves to '{request.path}', which is outside the configured server "
                f"base path '{base_path}'."
            )

    def get_server_url(self, server_url_override=None, api_host_url=None, arguments=None):
        """Get the server URL for the operation."""
        if arguments is None:
            arguments = {}

        # Prioritize server_url_override

View on GitHub (pinned to c028a0c7dc)

Solutions

  1. Ensure the operation path is relative and does not change the host/scheme/port of the configured server.
  2. Verify server variable argument values point to the same host as the base server URL.
  3. Correct the OpenAPI spec if a path legitimately needs to target a different server (use a separate server entry).

Example fix

// before (server variable redirects to different host)
await api.call_op(server_variables={"host": "evil.example.com"})
// after
await api.call_op(server_variables={"host": "api.example.com"})
Defensive patterns

Strategy: validation

Validate before calling

from urllib.parse import urlparse
def validate_server_match(server_url: str, request_url: str):
    s, r = urlparse(server_url), urlparse(request_url)
    if (r.scheme, r.hostname, r.port) != (s.scheme, s.hostname, s.port):
        raise ValueError(f"Request target {r.scheme}://{r.netloc} does not match server {s.scheme}://{s.netloc}")

Try / catch

try:
    result = await api.my_operation(**args)
except FunctionExecutionException as e:
    if "does not match the configured server" in str(e):
        # ensure server variable values keep the same host/scheme/port
        ...

Prevention

When it happens

Trigger: The operation path (after variable substitution and argument interpolation) resolves to a different scheme, host, or port than the configured server URL. For example a server variable substitution injects a different hostname, or the path contains an absolute URL.

Common situations: An OpenAPI spec path contains an absolute URL that overrides the server. A server URL variable is substituted with a value pointing to a different host. Malicious or malformed server-variable arguments. This guard complements the dot-segment and path-traversal checks.

Related errors


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