louislam/uptime-kuma · warning · Error

Invalid condition ${jsonPathOperator}

Error message

Invalid condition ${jsonPathOperator}

What it means

Thrown by evaluateJsonQuery()'s switch on jsonPathOperator when the value is not one of `>`, `>=`, `<`, `<=`, `!=`, `==`, `contains`. The operator selects the JSONata comparison expression, so an unrecognized operator cannot be compiled. The frontend default is "==" (EditMonitor.vue:3832), and the UI restricts the dropdown, but the server still guards against malformed DB values.

Source

Thrown at src/util.ts:750

        let jsonQueryExpression;
        switch (jsonPathOperator) {
            case ">":
            case ">=":
            case "<":
            case "<=":
                jsonQueryExpression = `$number($.value) ${jsonPathOperator} $number($.expected)`;
                break;
            case "!=":
                jsonQueryExpression = "$.value != $.expected";
                break;
            case "==":
                jsonQueryExpression = "$.value = $.expected";
                break;
            case "contains":
                jsonQueryExpression = "$contains($.value, $.expected)";
                break;
            default:
                throw new Error(`Invalid condition ${jsonPathOperator}`);
        }

        // Evaluate the JSON Query Expression
        const expression = jsonata(jsonQueryExpression);
        const status = await expression.evaluate({
            value: response.toString(),
            expected: expectedValue.toString(),
        });

        if (status === undefined) {
            throw new Error(
                "Query evaluation returned undefined. Check query syntax and the structure of the response data"
            );
        }

        return {
            status, // The evaluation of the json query
            response, // The response from the server or result from initial json-query evaluation

View on GitHub (pinned to 6b5ea01557)

Solutions

  1. Reset the operator to a supported value via the UI or DB: one of >, >=, <, <=, !=, ==, contains.
  2. Audit existing monitors: `SELECT id, jsonPathOperator FROM monitor WHERE jsonPathOperator NOT IN ('>','>=','<','<=','!=','==','contains')`.
  3. If building a programmatic client, restrict the operator input to the documented enum.
  4. Normalize case and trim whitespace before storing the operator.

Example fix

// before: monitor.jsonPathOperator = "="  -> falls through -> throws

// after
const allowed = [">", ">=", "<", "<=", "!=", "==", "contains"];
monitor.jsonPathOperator = allowed.includes(op) ? op : "==";
Defensive patterns

Strategy: validation

Validate before calling

const ALLOWED = [">", ">=", "<", "<=", "!=", "==", "contains"];
if (!ALLOWED.includes(operator)) operator = "==";

Type guard

const isAllowedOperator = (v) => typeof v === "string" && [">", ">=", "<", "<=", "!=", "==", "contains"].includes(v);

Try / catch

try { await evaluateJsonQuery(data, path, op, expected); } catch (e) { if (/Invalid condition/.test(e.message)) { op = "=="; /* retry */ } else throw e; }

Prevention

When it happens

Trigger: A monitor row whose jsonPathOperator column contains an unsupported value: "=", "eq", "<>", "===" (three equals), "contains " (trailing space), or empty string. This can happen via direct DB edits, a buggy migration, or a programmatic API client that sets the operator outside the allowed set.

Common situations: Database edited by hand; data imported from another tool with different operator vocabulary; older record with a value no longer accepted; whitespace/case typo ("Contains", "CONTAINS"); a frontend bug writing the wrong enum.

Related errors


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