{"record":{"id":"deead0d2fbe5c0df","repo":"microsoft/semantic-kernel","slug":"value-value-for-server-variable-variable-nam","errorCode":null,"errorMessage":"Value '{value}' for server variable '{variable_name}' is not one of the allowed values.","messagePattern":"Value '(.+?)' for server variable '(.+?)' is not one of the allowed values\\.","errorType":"exception","errorClass":"FunctionExecutionException","httpStatus":null,"severity":"error","filePath":"python/semantic_kernel/connectors/openapi_plugin/models/rest_api_operation.py","lineNumber":302,"sourceCode":"            server_url_string = server[\"url\"] if isinstance(server, dict) else server\n            server_variables = server.get(\"variables\", {}) if isinstance(server, dict) else {}\n\n            # Substitute server variables if available\n            for variable_name, variable_def in server_variables.items():\n                argument_name = variable_def.get(\"argument_name\", variable_name)\n                allowed_values = variable_def.get(\"enum\")\n                if argument_name in arguments:\n                    value = str(arguments[argument_name])\n                elif \"default\" in variable_def and variable_def[\"default\"] is not None:\n                    # Use the default value if no argument is provided\n                    value = str(variable_def[\"default\"])\n                else:\n                    # Raise an exception if no value is available\n                    raise FunctionExecutionException(\n                        f\"No argument provided for the '{variable_name}' server variable of the operation '{self.id}'.\"\n                    )\n                if allowed_values is not None and value not in allowed_values:\n                    raise FunctionExecutionException(\n                        f\"Value '{value}' for server variable '{variable_name}' is not one of the allowed values.\"\n                    )\n                server_url_string = server_url_string.replace(f\"{{{variable_name}}}\", quote(value, safe=\"\"))\n        elif self.server_url:\n            server_url_string = self.server_url\n        elif api_host_url is not None:\n            server_url_string = api_host_url\n        else:\n            raise FunctionExecutionException(f\"No valid server URL for operation {self.id}\")\n\n        # Ensure the base URL ends with a trailing slash\n        if not server_url_string.endswith(\"/\"):\n            server_url_string += \"/\"\n\n        return server_url_string  # Return the URL string directly\n\n    def build_path(self, path_template: str, arguments: dict[str, Any]) -> str:\n        \"\"\"Build the path for the operation.\"\"\"","sourceCodeStart":284,"sourceCodeEnd":320,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/python/semantic_kernel/connectors/openapi_plugin/models/rest_api_operation.py#L284-L320","documentation":"After resolving a server URL variable's value (from argument or default), `get_server_url` checks it against the variable's `enum` constraint if one is declared in the OpenAPI spec. If the value is not in the allowed list, this FunctionExecutionException is raised. This enforces the OpenAPI `enum` restriction on server URL variables.","triggerScenarios":"A server URL variable has an `enum` constraint in the OpenAPI spec, and the supplied argument value (or default) is not one of the allowed values. For example `enum: [us, eu]` but the caller passes `region=\"asia\"`.","commonSituations":"Caller passes a region/zone/environment value not in the spec's allowed list. The spec's default value is incorrectly not in its own enum. Case-sensitivity mismatch (e.g. `US` vs `us`).","solutions":["Provide a value that is listed in the variable's `enum` constraint in the OpenAPI spec.","Check for case-sensitivity and match the exact allowed values.","Update the OpenAPI spec's `enum` to include the needed value if the restriction is too narrow."],"exampleFix":"// before (region not in enum)\nawait api.call_op(region=\"asia\")  # enum is [us, eu]\n// after\nawait api.call_op(region=\"eu\")","handlingStrategy":"validation","validationCode":"def validate_server_variable_enum(operation, arguments: dict):\n    for server in (operation.servers or []):\n        for var_name, var_def in (server.get('variables') or {}).items():\n            allowed = var_def.get('enum')\n            if allowed is None:\n                continue\n            arg_name = var_def.get('argument_name', var_name)\n            value = str(arguments.get(arg_name, var_def.get('default', '')))\n            if value not in allowed:\n                raise ValueError(f\"Value '{value}' for '{var_name}' not in enum {allowed}\")","typeGuard":null,"tryCatchPattern":"try:\n    result = await api.my_operation(**args)\nexcept FunctionExecutionException as e:\n    if \"not one of the allowed values\" in str(e):\n        # provide a value from the variable's enum\n        ...","preventionTips":["Check the variable's enum constraint in the spec and provide an allowed value.","Watch for case-sensitivity in enum values.","Update the spec's enum if a legitimate value is missing."],"tags":["openapi","rest-api","server-variables","validation","semantic-kernel"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}