-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Description
Describe the bug
During OpenAPI metadata-ingestion there is a get_endpoints method that wrongly assumes that a Path Item Object is a dictionary with only string keys (methods) and Operation Object values. This is not the case for the keys parameters and servers which map to array values
This code fails: https://github.com/datahub-project/datahub/blob/v0.13.1/metadata-ingestion/src/datahub/ingestion/source/openapi_parser.py#L123C9-L123C30 with TypeError: list indices must be integers or slices, not str when the first item in the Path Item Object is a servers or parameters since their values are Arrays and not Operation Objects
It is valid to have a parameters key or a servers key that contain arrays: https://spec.openapis.org/oas/v3.0.1#path-item-object
To Reproduce
Steps to reproduce the behavior:
- Example Swagger snippet:
paths:
parameters:
- name: parameter
in: query
get:
responses:
...
Expected behavior
method = list(p_o)[0] should not assume that a method is the first item. It could be servers or parameters
This could fix it:
method = next(key for key in list(p_o) if key not in {'servers', 'parameters'})
Desktop (please complete the following information):
- OS: Linux
- Browser: N/A
- Version: v0.13.1
Additional context
Problematic code: https://github.com/datahub-project/datahub/blob/v0.13.1/metadata-ingestion/src/datahub/ingestion/source/openapi_parser.py#L123C9-L123C30
Path item object spec: https://spec.openapis.org/oas/v3.0.1#path-item-object