-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Closed
Copy link
Labels
bugSomething isn't workingSomething isn't workingpythonPull requests for the Python Semantic KernelPull requests for the Python Semantic Kernel
Description
Describe the bug
The fallback mechanism in handling an OpenAPI operation that doesn't have an operation ID may result in invalid kernel function name: https://github.com/microsoft/semantic-kernel/blob/main/python/semantic_kernel/connectors/openapi_plugin/openapi_parser.py#L239
Traceback (most recent call last):
File "C:\Users\taochen\Project\semantic-kernel\python\semantic_kernel\functions\kernel_function_from_method.py", line 69, in __init__
metadata = KernelFunctionMetadata(
^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\taochen\Project\semantic-kernel\python\.venv\Lib\site-packages\pydantic\main.py", line 253, in __init__
validated_self = self.__pydantic_validator__.validate_python(data, self_instance=self)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pydantic_core._pydantic_core.ValidationError: 1 validation error for KernelFunctionMetadata
name
String should match pattern '^[0-9A-Za-z_-]+$' [type=string_pattern_mismatch, input_value='/anything_patch', input_type=str]
For further information visit https://errors.pydantic.dev/2.11/v/string_pattern_mismatch
To Reproduce
Steps to reproduce the behavior:
- Go to sample: https://github.com/microsoft/semantic-kernel/tree/main/python/samples/concepts/plugins/openapi
- Open openapi.yaml
- Comment out line 11
- Run openapi_client.py
Expected behavior
The plugin is successfully added to the kernel.
Platform
- Language: Python
Additional context
We should either require the operationId
attribute or perform some more meaningful parsing and a more targeted error message.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingpythonPull requests for the Python Semantic KernelPull requests for the Python Semantic Kernel
Type
Projects
Status
No status
Milestone
Relationships
Development
Select code repository
Activity
[-]Bug: OpenAPI plugin function name parsing results in invalid kernel function name[/-][+]Python: Bug: OpenAPI plugin function name parsing results in invalid kernel function name[/+][-]Python: Bug: OpenAPI plugin function name parsing results in invalid kernel function name[/-][+]Bug: OpenAPI plugin function name parsing results in invalid kernel function name[/+]sshandilya1991 commentedon Jun 12, 2025
hey @TaoChenOSU / @moonbox3
I surmise this is due to this
I can raise a fix for this - but here is a question:
operationId
would be something like/users_get
which is going to fail the regex validation. So, question is to either to make the regex validation flexible or making sureoperationId
in details exists or maybe something else that I may be missing.thoughts?
Edit:
I see that anyway we are directly using operation.id in further functions assuming it's there anyway - so, IMO, we should simply have a validation for it & raise if it's not there or probably create one if not there in openapispec(wild thought) ?
moonbox3 commentedon Jun 19, 2025
Hi, @sshandilya1991, yes, we should have validation for it early on and raise if operationId isn't present.
Python: added operationid validation in openapi spec (#12551)