lucasheld / uptime-kuma-api

A Python wrapper for the Uptime Kuma Socket.IO API
https://uptime-kuma-api.readthedocs.io
MIT License
252 stars 19 forks source link

"None is not a valid AuthMethod" error #38

Closed mishac closed 1 year ago

mishac commented 1 year ago

After updating to 1.0 I'm getting the following error whenever I run an ansible task that lists/updates/creates monitors

       monitors = api.get_monitors()
                   ^^^^^^^^^^^^^^^^^^
      File "/home/mishac/Work/personal/home-infrastructure/lib/python3.11/site-packages/uptime_kuma_api/api.py", line 1021, in get_monitors
        parse_auth_method(r)
      File "/home/mishac/Work/personal/home-infrastructure/lib/python3.11/site-packages/uptime_kuma_api/api.py", line 73, in parse_auth_method
        parse_value(data, "authMethod", AuthMethod)
      File "/home/mishac/Work/personal/home-infrastructure/lib/python3.11/site-packages/uptime_kuma_api/api.py", line 57, in parse_value
        parse_value(d, key, type_)
      File "/home/mishac/Work/personal/home-infrastructure/lib/python3.11/site-packages/uptime_kuma_api/api.py", line 60, in parse_value
        data[key] = type_(data[key])
                    ^^^^^^^^^^^^^^^^
      File "/usr/lib/python3.11/enum.py", line 717, in __call__
        return cls.__new__(cls, value)
               ^^^^^^^^^^^^^^^^^^^^^^^
      File "/usr/lib/python3.11/enum.py", line 1133, in __new__
        raise ve_exc
    ValueError: None is not a valid AuthMethod

It looks like my monitors in uptime kuma don't have a valid auth mode set. deleting and recreating them fixes the issue, but there are dozens of monitors so it's a pain in the ass.

I guess a blank/invalid authmethod should be cast to Authmethod.NONE?

lucasheld commented 1 year ago

Thank you for reporting this bug. It should be fixed in uptime-kuma-api 1.0.1