louislam / uptime-kuma

A fancy self-hosted monitoring tool
https://uptime.kuma.pet
MIT License
60.3k stars 5.39k forks source link

[BUG] Error adding new monitor over API in v2: NOT NULL constraint failed: monitor.conditions #5360

Closed fp-big5 closed 6 days ago

fp-big5 commented 6 days ago

πŸ“‘ I have found these related issues/pull requests

None

πŸ›‘οΈ Security Policy

Description

I've built a python script to read all ingress objects in a kubernetes cluster and update/add them into uptime-kuma.

It is working in kuma:v1, besides having to change the timeout in the python API to over 90 seconds (you know, because it's slow at v1)

So, last week I saw the v2 beta and I'm trying it out.

So far, it's working as expected, BUT..

My script doesn't work anymore, apparently because a new "conditions" field are required:

python3 script.py

Monitor 'api-1' updated successfully.

Traceback (most recent call last):
  File "/home/fp/folder/script.py", line 94, in <module>
    api.add_monitor(**monitor_data)
  File "/home/fp/folder/venv/lib/python3.12/site-packages/uptime_kuma_api/api.py", line 1472, in add_monitor
    return self._call('add', data)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/fp/folder/venv/lib/python3.12/site-packages/uptime_kuma_api/api.py", line 550, in _call
    raise UptimeKumaException(r.get("msg"))
uptime_kuma_api.exceptions.UptimeKumaException: 

insert into `monitor` (`accepted_statuscodes_json`, `auth_method`, `body`, `conditions`, `database_connection_string`, `description`, `dns_resolve_server`, `dns_resolve_type`, `expiry_notification`, `headers`, `hostname`, `http_body_encoding`, `ignore_tls`, `interval`, `kafka_producer_brokers`, `kafka_producer_sasl_options`, `maxredirects`, `maxretries`, `method`, `mqtt_password`, `mqtt_success_message`, `mqtt_topic`, `mqtt_username`, `name`, `packet_size`, `parent`, `port`, `proxy_id`, `rabbitmq_nodes`, `resend_interval`, `retry_interval`, `timeout`, `type`, `upside_down`, `url`, `user_id`) 

values ('["200-299"]', '', NULL, NULL, NULL, NULL, '1.1.1.1', 'A', 'True', NULL, NULL, 'json', false, 60, NULL, NULL, 10, 10, 'GET', '', '', '', '', 'api-2', 56, 145, NULL, NULL, NULL, 3600, 60, 29, 'http', false, 'https://api-2.company.com/healthcheck', 1) - 

SQLITE_CONSTRAINT: NOT NULL constraint failed: monitor.conditions

But it seems that this field is not yet implemented in the API, since it throws this error when I try to pass it:

python3 script.py

Monitor 'api-1' updated successfully.

Traceback (most recent call last):

  File "/home/fp/folder/script.py", line 94, in <module>
    api.add_monitor(**monitor_data)

  File "/home/fp/folder/venv/lib/python3.12/site-packages/uptime_kuma_api/api.py", line 1468, in add_monitor
    data = self._build_monitor_data(**kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

TypeError: UptimeKumaApi._build_monitor_data() got an unexpected keyword argument 'conditions'

πŸ‘Ÿ Reproduction steps

try to add a new http monitor into uptimekuma:v2

πŸ‘€ Expected behavior

To be able to add monitors over the API.

πŸ˜“ Actual Behavior

The API throw this error:

SQLITE_CONSTRAINT: NOT NULL constraint failed: monitor.conditions

🐻 Uptime-Kuma Version

2.0.0-beta.0

πŸ’» Operating System and Arch

docker

🌐 Browser

uptime-kuma API

πŸ–₯️ Deployment Environment

πŸ“ Relevant log output

No response

louislam commented 6 days ago

Expected. It is not an official api.

The python library should be this: https://github.com/lucasheld/uptime-kuma-api

felipewnp commented 3 days ago

Hi @louislam

Correct, I'm using the library that you mentioned.

So, just to be clear..

There is no way to manage uptime-kuma v2 programmatically?