{"record":{"id":"b60d0fcbbd09fabb","repo":"louislam/uptime-kuma","slug":"json-query-does-not-pass-comparing-response-b60d0f","errorCode":null,"errorMessage":"JSON query does not pass (comparing ${response} ${monitor.jsonPathOperator} ${monitor.expectedValue})","messagePattern":"JSON query does not pass \\(comparing (.+?) (.+?) (.+?)\\)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"server/monitor-types/globalping.js","lineNumber":425,"sourceCode":"\n    /**\n     * Handles JSON query for HTTP monitors.\n     * @param {Monitor} monitor - The monitor object.\n     * @param {Heartbeat} heartbeat - The heartbeat object.\n     * @param {Result} result - The result object.\n     * @param {Probe} probe - The probe object.\n     * @returns {Promise<void>} A promise that resolves when the JSON query is handled.\n     */\n    async handleJSONQueryForHTTP(monitor, heartbeat, result, probe) {\n        const { status, response } = await evaluateJsonQuery(\n            result.rawOutput,\n            monitor.jsonPath,\n            monitor.jsonPathOperator,\n            monitor.expectedValue\n        );\n\n        if (!status) {\n            throw new Error(\n                this.formatResponse(\n                    probe,\n                    `JSON query does not pass (comparing ${response} ${monitor.jsonPathOperator} ${monitor.expectedValue})`\n                )\n            );\n        }\n\n        heartbeat.msg = this.formatResponse(\n            probe,\n            `JSON query passes (comparing ${response} ${monitor.jsonPathOperator} ${monitor.expectedValue})`\n        );\n        heartbeat.status = UP;\n    }\n\n    /**\n     * Updates the TLS information for a monitor.\n     * @param {object} monitor - The monitor object.\n     * @param {string} protocol - The protocol used for the monitor.","sourceCodeStart":407,"sourceCodeEnd":443,"githubUrl":"https://github.com/louislam/uptime-kuma/blob/6b5ea0155793e666666745fb8d6fef1e829543a2/server/monitor-types/globalping.js#L407-L443","documentation":"Thrown by handleJSONQueryForHTTP when evaluateJsonQuery returns status === false. The message echoes the actual response value, the operator, and the expected value so you can see exactly which comparison failed. This runs only when monitor.expectedValue is set (and no keyword took precedence).","triggerScenarios":"evaluateJsonQuery(result.rawOutput, monitor.jsonPath, monitor.jsonPathOperator, monitor.expectedValue) resolves with status false. E.g. jsonPath points to a field whose value does not satisfy the operator against expectedValue.","commonSituations":"The API response shape changed so jsonPath no longer resolves, the operator is wrong (e.g. '<' on a string), expectedValue type mismatch (string vs number), or the JSON body is not valid JSON.","solutions":["Compare the echoed 'response' value against expectedValue with the chosen operator","Verify monitor.jsonPath still resolves against the current response shape (use a JSONPath tester)","Ensure the operator is appropriate for the value's type","Confirm expectedValue is the correct type/string the API returns"],"exampleFix":"// before: wrong type comparison\nmonitor.jsonPath = \"$.status\";\nmonitor.jsonPathOperator = \"==\";\nmonitor.expectedValue = 200; // API returns \"ok\"\n// after\nmonitor.expectedValue = \"ok\";","handlingStrategy":"validation","validationCode":"// Validate JSONPath and operator before running\nconst validOps = ['==','!=','<','<=','>','>=','contains'];\nif (!validOps.includes(monitor.jsonPathOperator)) {\n    throw new Error(\"Invalid jsonPathOperator: \" + monitor.jsonPathOperator);\n}\ntry { jsonata(monitor.jsonPath); } catch {\n    throw new Error(\"Invalid JSONPath expression: \" + monitor.jsonPath);\n}","typeGuard":null,"tryCatchPattern":"const { status, response } = await evaluateJsonQuery(result.rawOutput, monitor.jsonPath, monitor.jsonPathOperator, monitor.expectedValue);\nif (!status) {\n    throw new Error(this.formatResponse(probe,\n        `JSON query does not pass (comparing ${response} ${monitor.jsonPathOperator} ${monitor.expectedValue})`));\n}","preventionTips":["Test the JSONPath against a sample response before enabling the monitor","Ensure the operator matches the value's data type","Set expectedValue to the same type the API returns"],"tags":["globalping","http","json-query","config"],"backgroundTag":null,"analyzedSha":"6b5ea0155793e666666745fb8d6fef1e829543a2","analyzedAt":"2026-08-12T23:42:12.959Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}