{"record":{"id":"bc1a4f62f5f0050c","repo":"microsoft/semantic-kernel","slug":"either-openapi-document-path-or-openapi-parsed","errorCode":null,"errorMessage":"Either `openapi_document_path` or `openapi_parsed_spec` must be provided.","messagePattern":"Either `openapi_document_path` or `openapi_parsed_spec` must be provided\\.","errorType":"exception","errorClass":"FunctionExecutionException","httpStatus":null,"severity":"error","filePath":"python/semantic_kernel/connectors/openapi_plugin/openapi_manager.py","lineNumber":54,"sourceCode":"    execution_settings: \"OpenAPIFunctionExecutionParameters | None\" = None,\n) -> list[KernelFunctionFromMethod]:\n    \"\"\"Creates the functions from OpenAPI document.\n\n    Args:\n        plugin_name: The name of the plugin\n        openapi_document_path: The OpenAPI document path, it must be a file path to the spec (optional)\n        openapi_parsed_spec: The parsed OpenAPI spec (optional)\n        execution_settings: The execution settings\n\n    Returns:\n        list[KernelFunctionFromMethod]: the operations as functions\n    \"\"\"\n    parsed_doc: dict[str, Any] | Any = None\n    if openapi_parsed_spec is not None:\n        parsed_doc = openapi_parsed_spec\n    else:\n        if openapi_document_path is None:\n            raise FunctionExecutionException(\n                \"Either `openapi_document_path` or `openapi_parsed_spec` must be provided.\"\n            )\n\n        # Parse the document from the given path\n        parser = OpenApiParser()\n        parsed_doc = parser.parse(\n            openapi_document_path,\n            enable_file_ref_resolution=(execution_settings.enable_file_ref_resolution if execution_settings else False),\n            enable_http_ref_resolution=(execution_settings.enable_http_ref_resolution if execution_settings else False),\n        )\n        if parsed_doc is None:\n            raise FunctionExecutionException(f\"Error parsing OpenAPI document: {openapi_document_path}\")\n\n    parser = OpenApiParser()\n    operations = parser.create_rest_api_operations(parsed_doc, execution_settings=execution_settings)\n\n    global_security_requirements = parsed_doc.get(\"security\", [])\n","sourceCodeStart":36,"sourceCodeEnd":72,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/python/semantic_kernel/connectors/openapi_plugin/openapi_manager.py#L36-L72","documentation":"`create_functions_from_openapi` requires at least one input: either a file path (`openapi_document_path`) or an already-parsed spec dict (`openapi_parsed_spec`). If both are `None`, it raises `FunctionExecutionException`. The plugin cannot synthesize a REST surface from nothing.","triggerScenarios":"Calling `kernel.add_openapi_plugin(plugin_name=\"x\")` or `create_functions_from_openapi(plugin_name=\"x\")` without supplying either `openapi_document_path` or `openapi_parsed_spec`. Also when a path variable read from config resolves to `None`.","commonSituations":"Forgetting to pass the spec argument; an env var / config key for the spec path being unset; refactoring a wrapper that previously defaulted the path; CI running with a missing mounted spec file passed as `None`.","solutions":["Pass `openapi_document_path=\"/path/to/openapi.yaml\"` with a real file path.","Or pass `openapi_parsed_spec=<dict>` containing the parsed document.","In your wrapper, assert the spec source is not None before calling the kernel API.","Log the resolved path/spec at startup so a misconfigured env var is obvious."],"exampleFix":"# before\nkernel.add_openapi_plugin(plugin_name=\"pets\")  # raises 1484\n\n# after\nkernel.add_openapi_plugin(plugin_name=\"pets\", openapi_document_path=\"/specs/pets.yaml\")","handlingStrategy":"validation","validationCode":"def resolve_spec_source(path=None, parsed=None):\n    if parsed is not None:\n        return parsed, None\n    if path is None:\n        raise ValueError(\"Must provide openapi_document_path or openapi_parsed_spec\")\n    return None, path\n\nparsed, path = resolve_spec_source(cfg.get(\"path\"), cfg.get(\"spec\"))\nkwargs = {\"openapi_parsed_spec\": parsed} if parsed else {\"openapi_document_path\": path}\nkernel.add_openapi_plugin(plugin_name=\"x\", **kwargs)","typeGuard":"def has_spec_source(path=None, parsed=None) -> bool:\n    return path is not None or parsed is not None","tryCatchPattern":"from semantic_kernel.exceptions import FunctionExecutionException\n\ntry:\n    kernel.add_openapi_plugin(plugin_name=\"x\", openapi_document_path=path)\nexcept FunctionExecutionException as e:\n    if \"must be provided\" in str(e):\n        raise ConfigError(\"OpenAPI spec source not configured\") from e\n    raise","preventionTips":["Fail fast in your wrapper if neither spec source is set.","Log the resolved path at startup.","Mount spec files in CI explicitly rather than via env defaults.","Add a config schema that requires one of the two fields."],"tags":["openapi-plugin","config","semantic-kernel"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}