Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Health is broken #5

Closed
RomLecat opened this issue Mar 14, 2023 · 6 comments
Closed

Health is broken #5

RomLecat opened this issue Mar 14, 2023 · 6 comments

Comments

@RomLecat
Copy link

RomLecat commented Mar 14, 2023

Hello,

The health API is not working.
When there's no health issue going on, the list_health() call returns an empty list, as expected.

However, if there's at least one health item present, it crashes:

Traceback (most recent call last):
  File "pydantic/main.py", line 522, in pydantic.main.BaseModel.parse_obj
ValueError: dictionary update sequence element #0 has length 1; 2 is required

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/opt/zabbix-tools/./arr_agent.py", line 64, in <module>
    main()
  File "/opt/zabbix-tools/./arr_agent.py", line 31, in main
    process_radarr(url, api_key, host['host'])
  File "/opt/zabbix-tools/./arr_agent.py", line 47, in process_radarr
    health = radarr.HealthApi(api_client).list_health()
  File "pydantic/decorator.py", line 40, in pydantic.decorator.validate_arguments.validate.wrapper_function
  File "pydantic/decorator.py", line 134, in pydantic.decorator.ValidatedFunction.call
  File "pydantic/decorator.py", line 206, in pydantic.decorator.ValidatedFunction.execute
  File "/usr/local/lib/python3.9/dist-packages/radarr/api/health_api.py", line 212, in list_health
    return self.list_health_with_http_info(**kwargs)  # noqa: E501
  File "pydantic/decorator.py", line 40, in pydantic.decorator.validate_arguments.validate.wrapper_function
  File "pydantic/decorator.py", line 134, in pydantic.decorator.ValidatedFunction.call
  File "pydantic/decorator.py", line 206, in pydantic.decorator.ValidatedFunction.execute
  File "/usr/local/lib/python3.9/dist-packages/radarr/api/health_api.py", line 303, in list_health_with_http_info
    return self.api_client.call_api(
  File "/usr/local/lib/python3.9/dist-packages/radarr/api_client.py", line 407, in call_api
    return self.__call_api(resource_path, method,
  File "/usr/local/lib/python3.9/dist-packages/radarr/api_client.py", line 248, in __call_api
    return_data = self.deserialize(response_data, response_type)
  File "/usr/local/lib/python3.9/dist-packages/radarr/api_client.py", line 318, in deserialize
    return self.__deserialize(data, response_type)
  File "/usr/local/lib/python3.9/dist-packages/radarr/api_client.py", line 334, in __deserialize
    return [self.__deserialize(sub_data, sub_kls)
  File "/usr/local/lib/python3.9/dist-packages/radarr/api_client.py", line 334, in <listcomp>
    return [self.__deserialize(sub_data, sub_kls)
  File "/usr/local/lib/python3.9/dist-packages/radarr/api_client.py", line 357, in __deserialize
    return self.__deserialize_model(data, klass)
  File "/usr/local/lib/python3.9/dist-packages/radarr/api_client.py", line 749, in __deserialize_model
    return klass.from_dict(data)
  File "/usr/local/lib/python3.9/dist-packages/radarr/models/health_resource.py", line 92, in from_dict
    "wiki_url": HttpUri.from_dict(obj.get("wikiUrl")) if obj.get("wikiUrl") is not None else None
  File "/usr/local/lib/python3.9/dist-packages/radarr/models/http_uri.py", line 109, in from_dict
    return HttpUri.parse_obj(obj)
  File "pydantic/main.py", line 525, in pydantic.main.BaseModel.parse_obj
pydantic.error_wrappers.ValidationError: 1 validation error for HttpUri
__root__
  HttpUri expected dict not str (type=type_error)

Tested using the following snippet:

    config = sonarr.Configuration(host=url)
    config.api_key['apikey'] = api_key
    with sonarr.ApiClient(config) as api_client:
        health = sonarr.HealthApi(api_client).list_health()
        print(health)

Radarr shows the exact same behaviour.

Thanks

@Fuochi
Copy link
Contributor

Fuochi commented Mar 15, 2023

Hi @RomLecat,
Thanks for pointing this out, the sdk is brand new and I'm still figuring some things out.

I think this issue is related to the way they define the "HttpUri" object (or at least how I parse the same):

https://github.com/Sonarr/Sonarr/blob/21045127cdbacb2d5035c46d116826c92d20b99e/src/Sonarr.Api.V3/openapi.json#L8041

I had the same issue with "TimeSpan", I'll create an exception to fix this, but probably next week.

@RomLecat
Copy link
Author

No worries !
This is a an awesome project, I'm really glad it exists :).

Fuochi added a commit that referenced this issue Mar 20, 2023
Fuochi added a commit that referenced this issue Mar 20, 2023
Fuochi added a commit that referenced this issue Mar 20, 2023
Fuochi added a commit that referenced this issue Mar 20, 2023
@Fuochi
Copy link
Contributor

Fuochi commented Mar 20, 2023

Hi @RomLecat,
I should've fixed both this and #6 in main branch, could you please check if it works as expected?
If this works, I'll release v0.6.0 and update radarr accordingly.

I'm working the sdk generation automation. Hence I'll propagate these fixes to other sdks once it's finished.

@RomLecat
Copy link
Author

Hi,

Just did some tests, I now have auth issues (I double-checked that my URL and API key are correct):

Traceback (most recent call last):
  File "/opt/zabbix-tools/./arr_agent.py", line 69, in <module>
    main()
  File "/opt/zabbix-tools/./arr_agent.py", line 43, in main
    process_sonarr(url, api_key, host['host'])
  File "/opt/zabbix-tools/./arr_agent.py", line 58, in process_sonarr
    queue = sonarr.QueueApi(api_client).get_queue(include_unknown_series_items=True, include_series=True, include_episode=True)
  File "pydantic/decorator.py", line 40, in pydantic.decorator.validate_arguments.validate.wrapper_function
  File "pydantic/decorator.py", line 134, in pydantic.decorator.ValidatedFunction.call
  File "pydantic/decorator.py", line 206, in pydantic.decorator.ValidatedFunction.execute
  File "/usr/local/lib/python3.9/dist-packages/sonarr/api/queue_api.py", line 384, in get_queue
    return self.get_queue_with_http_info(include_unknown_series_items, include_series, include_episode, **kwargs)  # noqa: E501
  File "pydantic/decorator.py", line 40, in pydantic.decorator.validate_arguments.validate.wrapper_function
  File "pydantic/decorator.py", line 134, in pydantic.decorator.ValidatedFunction.call
  File "pydantic/decorator.py", line 206, in pydantic.decorator.ValidatedFunction.execute
  File "/usr/local/lib/python3.9/dist-packages/sonarr/api/queue_api.py", line 490, in get_queue_with_http_info
    return self.api_client.call_api(
  File "/usr/local/lib/python3.9/dist-packages/sonarr/api_client.py", line 407, in call_api
    return self.__call_api(resource_path, method,
  File "/usr/local/lib/python3.9/dist-packages/sonarr/api_client.py", line 222, in __call_api
    raise e
  File "/usr/local/lib/python3.9/dist-packages/sonarr/api_client.py", line 212, in __call_api
    response_data = self.request(
  File "/usr/local/lib/python3.9/dist-packages/sonarr/api_client.py", line 433, in request
    return self.rest_client.get_request(url,
  File "/usr/local/lib/python3.9/dist-packages/sonarr/rest.py", line 235, in get_request
    return self.request("GET", url,
  File "/usr/local/lib/python3.9/dist-packages/sonarr/rest.py", line 218, in request
    raise UnauthorizedException(http_resp=r)
sonarr.exceptions.UnauthorizedException: (401)
Reason: Unauthorized
HTTP response headers: HTTPHeaderDict({'Alt-Svc': 'h3=":8443"; ma=2592000,h3-29=":8443"; ma=2592000', 'Content-Length': '0', 'Date': 'Mon, 20 Mar 2023 07:32:14 GMT', 'Server': 'Kestrel'})

@RomLecat
Copy link
Author

RomLecat commented Mar 20, 2023

My bad, I swapped configuration.api_key['apikey'] to configuration.api_key['X-Api-Key'] and it seems to work.

I tested health by putting a buggy download client, it is properly reported. The queue is empty (so no more errors), I'll test it once my radarr picks something.

Thanks a lot ! :)

@Fuochi
Copy link
Contributor

Fuochi commented Mar 24, 2023

No problem, I'm thinking of decommissioning 'apikey' as I don't like passing the key as query parameter.

Still, I've updated all the SDKs with the latest configurations, and created the relative releases.
Please be mindful that at this early stages some changes may be disruptive without notice. Feel free to open new tickets if you incur in any issue.

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants