{"record":{"id":"ef3c8ea192df735f","repo":"microsoft/semantic-kernel","slug":"no-argument-variable-value-argumentname-varia","errorCode":null,"errorMessage":"No argument '{variable.Value.ArgumentName ?? variableName}' provided for the '{variableName}' server variable of the operation - '{this.Id}'.","messagePattern":"No argument '(.+?)' provided for the '(.+?)' server variable of the operation - '(.+?)'\\.","errorType":"exception","errorClass":"KernelException","httpStatus":null,"severity":"error","filePath":"dotnet/src/Functions/Functions.OpenApi/Model/RestApiOperation.cs","lineNumber":421,"sourceCode":"                {\n                    serverUrlString = serverUrlString.Replace($\"{{{variableName}}}\", Uri.EscapeDataString(argStrValue));\n                }\n                // Try to get the variable value by the variable name.\n                else if (arguments.TryGetValue(variableName, out value) &&\n                    value is string { } strValue &&\n                    variable.Value.IsValid(strValue))\n                {\n                    serverUrlString = serverUrlString.Replace($\"{{{variableName}}}\", Uri.EscapeDataString(strValue));\n                }\n                // Use the default value if no argument is provided.\n                else if (variable.Value.Default is not null)\n                {\n                    serverUrlString = serverUrlString.Replace($\"{{{variableName}}}\", variable.Value.Default);\n                }\n                // Throw an exception if there's no value for the variable.\n                else\n                {\n                    throw new KernelException($\"No argument '{variable.Value.ArgumentName ?? variableName}' provided for the '{variableName}' server variable of the operation - '{this.Id}'.\");\n                }\n            }\n        }\n        else\n        {\n            serverUrlString =\n                apiHostUrl?.AbsoluteUri ??\n                throw new InvalidOperationException($\"Server url is not defined for operation {this.Id}\");\n        }\n\n        // Make sure base url ends with trailing slash\n        if (!serverUrlString.EndsWith(\"/\", StringComparison.OrdinalIgnoreCase))\n        {\n            serverUrlString += \"/\";\n        }\n\n        return new Uri(serverUrlString);\n    }","sourceCodeStart":403,"sourceCodeEnd":439,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/dotnet/src/Functions/Functions.OpenApi/Model/RestApiOperation.cs#L403-L439","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before - server variable 'region' has no value and no default\n\"servers\": [ { \"url\": \"https://{region}.api.com\", \"variables\": { \"region\": { \"enum\": [\"us\",\"eu\"] } } } ]\n\n// after - supply the region argument at invocation\nvar args = new KernelArguments { [\"region\"] = \"us\" };\nvar result = await kernel.InvokeAsync(plugin[\"op\"], args);","handlingStrategy":"validation","validationCode":"foreach (var server in operation.Servers)\n    foreach (var kv in server.Variables)\n    {\n        var key = kv.Value.ArgumentName ?? kv.Key;\n        var hasVal = arguments.TryGetValue(key, out var v) && v is string s && kv.Value.IsValid(s);\n        if (!hasVal && kv.Value.Default is null)\n            throw new ArgumentException($\"Provide server variable '{key}' for operation '{operation.Id}'.\");\n    }","typeGuard":"static bool HasAllServerVariables(RestApiOperation op, IDictionary<string,object?> args)\n    => op.Servers.SelectMany(s => s.Variables).All(kv =>\n       { var key = kv.Value.ArgumentName ?? kv.Key;\n         return (args.TryGetValue(key, out var v) && v is string s && kv.Value.IsValid(s)) || kv.Value.Default is not null; });","tryCatchPattern":"try { var url = operation.BuildOperationUrl(arguments); }\ncatch (KernelException ex) when (ex.Message.Contains(\"server variable of the operation\"))\n{ logger.LogWarning(ex, \"Missing server variable; supply it or add a default.\"); throw; }","preventionTips":["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."],"tags":["openapi","rest-operation","server-url","server-variable","invocation"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}