buildarr / buildarr-sonarr

Sonarr PVR plugin for Buildarr
https://buildarr.github.io/plugins/sonarr
GNU General Public License v3.0
2 stars 4 forks source link

sonarr dump-config: 'ValueError' for empty fields in qBittorrent settings #39

Closed captrik closed 9 months ago

captrik commented 9 months ago

Hi, I was trying to build a buildarr configuration from my existing setup when I stumbled upon the following issue:

The command dump-config throws the following error when the (advanced) setting Url Base for qBittorrent is empty:

ValueError: 'value' attribute not included for remote field 'urlBase' and 'field_default' not defined in local attribute

The same error occurs for the setting Post-Import Category.

This can be worked around by setting values for those two properties (i.e. "/" for Url Base and the same value as in Category for Post-Import Category)
(Settings > Download Clients > Show Advanced Settings > qBittorrent)

I get the same result running with docker and running buildarr directly.
Used versions: buildarr-0.7.1 & buildarr-sonarr-0.6.1

Here is the full stacktrace running with docker:
docker run -it --rm callum027/buildarr:latest sonarr dump-config http://sonarr:8989

Sonarr instance API key (or leave blank to auto-fetch): 
Traceback (most recent call last):
  File "/usr/local/bin/buildarr", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/usr/local/lib/python3.11/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/buildarr_sonarr/cli.py", line 92, in dump_config
    .from_remote(
     ^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/buildarr/manager/__init__.py", line 171, in from_remote
    return instance_config.from_remote(secrets)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/buildarr_sonarr/config/__init__.py", line 323, in from_remote
    settings=SonarrSettingsConfig.from_remote(secrets),
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/buildarr/config/base.py", line 85, in from_remote
    fields[field_name] = field.type_.from_remote(secrets)
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/buildarr_sonarr/config/download_clients/__init__.py", line 155, in from_remote
    "definitions": {
                   ^
  File "/usr/local/lib/python3.11/site-packages/buildarr_sonarr/config/download_clients/__init__.py", line 158, in <dictcomp>
    ]._from_remote(
      ^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/buildarr_sonarr/config/download_clients/download_clients.py", line 323, in _from_remote
    **cls.get_local_attrs(
      ^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/buildarr/config/base.py", line 215, in get_local_attrs
    raise ValueError(
ValueError: 'value' attribute not included for remote field 'urlBase' and 'field_default' not defined in local attribute

Thank you for your work!

PS: It seems that the error isn't thrown after those two properties have been set and then reset to an empty value.

Callum027 commented 9 months ago

Hi there, thanks for trying out Buildarr.

This is an issue with managing Sonarr instances specifically, so I have moved the issue to the appropriate tracker.

Thanks for prividing the full backtrace, and details of what is happening. It looks like Buildarr is expecting Sonarr to provide a value of null by default in the Sonarr API response when Url Base is empty, but instead no default value is provided at all.

This should be a simple issue to fix, and I'll get a fix released when I have time during the day.

Callum027 commented 9 months ago

The same will be happening for Post-Import Categories (and probably Categories, as well), so I will make sure they are set in the same way.

Callum027 commented 9 months ago

Thanks for waiting. The fix for this issue has been released as:

Please give the new version a try to check that it resolves your issue.

captrik commented 9 months ago

Ok wow that was quick

Yes, can confirm buildarr:0.7.3 works. (with the same setup where buildarr:0.7.2 threw an error)

Thank you!

Callum027 commented 9 months ago

Glad it's working for you!