louislam/uptime-kuma · error · Error

Conditions must be valid JSON: ${e.message}

Error message

Conditions must be valid JSON: ${e.message}

What it means

validate() runs JSON.parse on the conditions field used by conditional monitoring logic. It must be valid JSON.

Source

Thrown at server/model/monitor.js:1673

                JSON.parse(this.kafkaProducerSaslOptions);
            } catch (e) {
                throw new Error(`Kafka Producer SASL Options must be valid JSON: ${e.message}`);
            }
        }

        if (this.rabbitmqNodes) {
            try {
                JSON.parse(this.rabbitmqNodes);
            } catch (e) {
                throw new Error(`RabbitMQ Nodes must be valid JSON: ${e.message}`);
            }
        }

        if (this.conditions) {
            try {
                JSON.parse(this.conditions);
            } catch (e) {
                throw new Error(`Conditions must be valid JSON: ${e.message}`);
            }
        }

        if (this.headers) {
            try {
                JSON.parse(this.headers);
            } catch (e) {
                throw new Error(`Headers must be valid JSON: ${e.message}`);
            }
        }

        if (this.accepted_statuscodes_json) {
            try {
                JSON.parse(this.accepted_statuscodes_json);
            } catch (e) {
                throw new Error(`Accepted status codes must be valid JSON: ${e.message}`);
            }
        }

View on GitHub (pinned to 6b5ea01557)

Solutions

  1. Provide conditions as valid JSON in the documented shape
  2. Validate with JSON.parse before saving
Defensive patterns

Strategy: validation

Validate before calling

if (monitor.conditions) { JSON.parse(monitor.conditions); } // throws if invalid

Type guard

function isValidJsonField(v) { if (!v) return true; try { JSON.parse(v); return true; } catch { return false; } }

Try / catch

try { monitor.validate(); await save(monitor); } catch (e) { /* surface e.message */ }

Prevention

When it happens

Trigger: conditions holds a non-JSON string when the monitor relies on conditional rules.

Common situations: Hand-editing the conditions outside the UI; partial/corrupted JSON from a migration.

Related errors


AI-assisted analysis of louislam/uptime-kuma@6b5ea01557 (2026-08-12). Data as JSON: /api/errors/684ddfe6651d42a5. Report an issue: GitHub.