You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Some endpoints can return data and empty response payload.
For example this PR #477 is introducing URL Monitoring endpoints, but get endpoint can return Datasequence and None which is breaking the api.
Traceback (most recent call last):
File "/home/jakub/work/demo/snadbox.py", line 65, in <module>
response = session.endpoints.url_monitoring.get_url_monitor()
File "/home/jakub/work/catalystwan/catalystwan/endpoints/__init__.py", line 568, in wrapper
return response.dataseq(self.return_spec.payload_type, self.resp_json_key)
File "/home/jakub/work/catalystwan/catalystwan/response.py", line 198, in dataseq
return DataSequence(cls, [cls.model_validate(item) for item in sequence]) # type: ignore
File "/home/jakub/work/catalystwan/catalystwan/response.py", line 198, in <listcomp>
return DataSequence(cls, [cls.model_validate(item) for item in sequence]) # type: ignore
File "/home/jakub/.cache/pypoetry/virtualenvs/catalystwan-UKVG-1nx-py3.10/lib/python3.10/site-packages/pydantic/main.py", line 551, in model_validate
return cls.__pydantic_validator__.validate_python(
pydantic_core._pydantic_core.ValidationError: 1 validation error for UrlMonitoringInfo
Input should be a valid dictionary or instance of UrlMonitoringInfo [type=model_type, input_value=None, input_type=NoneType]
For further information visit https://errors.pydantic.dev/2.7/v/model_type
Replication script (URL monitoring have to be empty)
We can't add the Optional field for the endpoint because we will get error
Traceback (most recent call last):
File "/home/jakub/work/demo/snadbox.py", line 6, in <module>
from catalystwan.endpoints.url_monitoring import UrlMonitoring
File "/home/jakub/work/catalystwan/catalystwan/endpoints/url_monitoring.py", line 12, in <module>
class UrlMonitoring(APIEndpoints):
File "/home/jakub/work/catalystwan/catalystwan/endpoints/url_monitoring.py", line 14, in UrlMonitoring
def get_url_monitor(self) -> Optional[DataSequence[UrlMonitoringInfo]]:
File "/home/jakub/work/catalystwan/catalystwan/endpoints/__init__.py", line 529, in __call__
self.return_spec = self.specify_return_type()
File "/home/jakub/work/catalystwan/catalystwan/endpoints/__init__.py", line 393, in specify_return_type
raise APIEndpointError(f"Expected: {ReturnType} but return type {annotation}")
catalystwan.exceptions.APIEndpointError: Expected: typing.Union[NoneType, str, int, float, bool, typing.Dict[str, ForwardRef('JSON')], typing.List[ForwardRef('JSON')], bytes, dict, pydantic.main.BaseModel, catalystwan.typed_list.DataSequence[pydantic.main.BaseModel]] but return type typing.Optional[catalystwan.typed_list.DataSequence[catalystwan.models.url_monitoring.UrlMonitoringInfo]]
The text was updated successfully, but these errors were encountered:
Description
Some endpoints can return data and empty response payload.
For example this PR #477 is introducing URL Monitoring endpoints, but get endpoint can return Datasequence and None which is breaking the api.
Replication script (URL monitoring have to be empty)
We can't add the Optional field for the endpoint because we will get error
The text was updated successfully, but these errors were encountered: