microsoft/semantic-kernel · error · KernelException
No argument '{variable.Value.ArgumentName ?? variableName}'
Error message
No argument '{variable.Value.ArgumentName ?? variableName}' provided for the '{variableName}' server variable of the operation - '{this.Id}'. What it means
Thrown by GetServerUrl when resolving a templated server URL: a server variable (e.g. {username} in 'https://{username}.example.com') has no valid argument under its ArgumentName or Name and no Default value defined in the spec. Without a value the URL cannot be constructed, so the call fails before any network activity.
Source
Thrown at dotnet/src/Functions/Functions.OpenApi/Model/RestApiOperation.cs:421
{
serverUrlString = serverUrlString.Replace($"{{{variableName}}}", Uri.EscapeDataString(argStrValue));
}
// Try to get the variable value by the variable name.
else if (arguments.TryGetValue(variableName, out value) &&
value is string { } strValue &&
variable.Value.IsValid(strValue))
{
serverUrlString = serverUrlString.Replace($"{{{variableName}}}", Uri.EscapeDataString(strValue));
}
// Use the default value if no argument is provided.
else if (variable.Value.Default is not null)
{
serverUrlString = serverUrlString.Replace($"{{{variableName}}}", variable.Value.Default);
}
// Throw an exception if there's no value for the variable.
else
{
throw new KernelException($"No argument '{variable.Value.ArgumentName ?? variableName}' provided for the '{variableName}' server variable of the operation - '{this.Id}'.");
}
}
}
else
{
serverUrlString =
apiHostUrl?.AbsoluteUri ??
throw new InvalidOperationException($"Server url is not defined for operation {this.Id}");
}
// Make sure base url ends with trailing slash
if (!serverUrlString.EndsWith("/", StringComparison.OrdinalIgnoreCase))
{
serverUrlString += "/";
}
return new Uri(serverUrlString);
}View on GitHub (pinned to c028a0c7dc)
Solutions
- Supply the server variable value in KernelArguments under the variable's name (or its sanitized ArgumentName).
- If the variable has an allowed set, provide one of the enum values; otherwise add a 'default' to servers[].variables in the spec.
- Pre-resolve the server by passing OpenApiFunctionExecutionParameters.ServerUrlOverride with the variables already substituted, bypassing template resolution.
Example fix
// before - server variable 'region' has no value and no default
"servers": [ { "url": "https://{region}.api.com", "variables": { "region": { "enum": ["us","eu"] } } } ]
// after - supply the region argument at invocation
var args = new KernelArguments { ["region"] = "us" };
var result = await kernel.InvokeAsync(plugin["op"], args); Defensive patterns
Strategy: validation
Validate before calling
foreach (var server in operation.Servers)
foreach (var kv in server.Variables)
{
var key = kv.Value.ArgumentName ?? kv.Key;
var hasVal = arguments.TryGetValue(key, out var v) && v is string s && kv.Value.IsValid(s);
if (!hasVal && kv.Value.Default is null)
throw new ArgumentException($"Provide server variable '{key}' for operation '{operation.Id}'.");
} Type guard
static bool HasAllServerVariables(RestApiOperation op, IDictionary<string,object?> args)
=> op.Servers.SelectMany(s => s.Variables).All(kv =>
{ var key = kv.Value.ArgumentName ?? kv.Key;
return (args.TryGetValue(key, out var v) && v is string s && kv.Value.IsValid(s)) || kv.Value.Default is not null; }); Try / catch
try { var url = operation.BuildOperationUrl(arguments); }
catch (KernelException ex) when (ex.Message.Contains("server variable of the operation"))
{ logger.LogWarning(ex, "Missing server variable; supply it or add a default."); throw; } Prevention
- Supply every templated server variable by name.
- Add a default to servers[].variables in the spec for variables with a known value.
- Use ServerUrlOverride to bypass template resolution entirely.
When it happens
Trigger: An OpenAPI document whose servers[].url uses template variables (curly braces) and the invocation does not supply a value for one of them, and that variable has no 'default' in servers[].variables. The lookup also validates the value via variable.IsValid (enum pattern), so an invalid enum value falls through to this same throw.
Common situations: A spec with per-tenant or per-region server templates where the caller forgets to pass the variable; an enum-constrained variable where the supplied value does not match an allowed entry; a spec whose variable has no default and the agent does not know to supply it.
Related errors
- The operation path resolves to '{requestAuthority}', which d
- No argument '{parameter.ArgumentName ?? parameter.Name}' is
- Server url is not defined for operation {this.Id}
- Payload parameters cannot be retrieved from the '{operation.
- The operation path resolves to '{requestPath}', which is out
AI-assisted analysis of microsoft/semantic-kernel@c028a0c7dc (2026-08-13).
Data as JSON: /api/errors/ef3c8ea192df735f.
Report an issue: GitHub.