{"record":{"id":"0d0b8884d8649c07","repo":"louislam/uptime-kuma","slug":"invalid-condition-jsonpathoperator","errorCode":null,"errorMessage":"Invalid condition ${jsonPathOperator}","messagePattern":"Invalid condition (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"src/util.ts","lineNumber":750,"sourceCode":"        let jsonQueryExpression;\n        switch (jsonPathOperator) {\n            case \">\":\n            case \">=\":\n            case \"<\":\n            case \"<=\":\n                jsonQueryExpression = `$number($.value) ${jsonPathOperator} $number($.expected)`;\n                break;\n            case \"!=\":\n                jsonQueryExpression = \"$.value != $.expected\";\n                break;\n            case \"==\":\n                jsonQueryExpression = \"$.value = $.expected\";\n                break;\n            case \"contains\":\n                jsonQueryExpression = \"$contains($.value, $.expected)\";\n                break;\n            default:\n                throw new Error(`Invalid condition ${jsonPathOperator}`);\n        }\n\n        // Evaluate the JSON Query Expression\n        const expression = jsonata(jsonQueryExpression);\n        const status = await expression.evaluate({\n            value: response.toString(),\n            expected: expectedValue.toString(),\n        });\n\n        if (status === undefined) {\n            throw new Error(\n                \"Query evaluation returned undefined. Check query syntax and the structure of the response data\"\n            );\n        }\n\n        return {\n            status, // The evaluation of the json query\n            response, // The response from the server or result from initial json-query evaluation","sourceCodeStart":732,"sourceCodeEnd":768,"githubUrl":"https://github.com/louislam/uptime-kuma/blob/6b5ea0155793e666666745fb8d6fef1e829543a2/src/util.ts#L732-L768","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Reset the operator to a supported value via the UI or DB: one of >, >=, <, <=, !=, ==, contains.","Audit existing monitors: `SELECT id, jsonPathOperator FROM monitor WHERE jsonPathOperator NOT IN ('>','>=','<','<=','!=','==','contains')`.","If building a programmatic client, restrict the operator input to the documented enum.","Normalize case and trim whitespace before storing the operator."],"exampleFix":"// before: monitor.jsonPathOperator = \"=\"  -> falls through -> throws\n\n// after\nconst allowed = [\">\", \">=\", \"<\", \"<=\", \"!=\", \"==\", \"contains\"];\nmonitor.jsonPathOperator = allowed.includes(op) ? op : \"==\";","handlingStrategy":"validation","validationCode":"const ALLOWED = [\">\", \">=\", \"<\", \"<=\", \"!=\", \"==\", \"contains\"];\nif (!ALLOWED.includes(operator)) operator = \"==\";","typeGuard":"const isAllowedOperator = (v) => typeof v === \"string\" && [\">\", \">=\", \"<\", \"<=\", \"!=\", \"==\", \"contains\"].includes(v);","tryCatchPattern":"try { await evaluateJsonQuery(data, path, op, expected); } catch (e) { if (/Invalid condition/.test(e.message)) { op = \"==\"; /* retry */ } else throw e; }","preventionTips":["Restrict the operator input to the documented enum.","Audit the DB for stray operator values.","Trim and normalize case before storing."],"tags":["json-query","jsonata","monitor","validation","operator","uptime-kuma"],"backgroundTag":null,"analyzedSha":"6b5ea0155793e666666745fb8d6fef1e829543a2","analyzedAt":"2026-08-12T23:42:12.959Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}