{"record":{"id":"ea5dcef47ff0f9f2","repo":"louislam/uptime-kuma","slug":"json-query-does-not-pass-comparing-response-ea5dce","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":"warning","filePath":"server/monitor-types/snmp.js","lineNumber":74,"sourceCode":"            if (varbinds[0].type === snmp.ObjectType.NoSuchInstance) {\n                throw new Error(`The SNMP query returned that no instance exists for OID ${monitor.snmpOid}`);\n            }\n\n            // We restrict querying to one OID per monitor, therefore `varbinds[0]` will always contain the value we're interested in.\n            const value = varbinds[0].value;\n\n            const { status, response } = await evaluateJsonQuery(\n                value,\n                monitor.jsonPath,\n                monitor.jsonPathOperator,\n                monitor.expectedValue\n            );\n\n            if (status) {\n                heartbeat.status = UP;\n                heartbeat.msg = `JSON query passes (comparing ${response} ${monitor.jsonPathOperator} ${monitor.expectedValue})`;\n            } else {\n                throw new Error(\n                    `JSON query does not pass (comparing ${response} ${monitor.jsonPathOperator} ${monitor.expectedValue})`\n                );\n            }\n        } finally {\n            if (session) {\n                session.close();\n            }\n        }\n    }\n}\n\nmodule.exports = {\n    SNMPMonitorType,\n};\n","sourceCodeStart":56,"sourceCodeEnd":89,"githubUrl":"https://github.com/louislam/uptime-kuma/blob/6b5ea0155793e666666745fb8d6fef1e829543a2/server/monitor-types/snmp.js#L56-L89","documentation":"Thrown when evaluateJsonQuery() resolves with status === false. The SNMP value was retrieved successfully and parsed, but it did not satisfy the configured jsonPath/jsonPathOperator/expectedValue predicate. This is an expected DOWN heartbeat path, not a crash: the monitor ran correctly and reported that the comparison failed.","triggerScenarios":"Triggered whenever the operator predicate (==, <, >, contains, etc.) applied to the extracted response and expectedValue yields false. For example, CPU load returned 95 but expectedValue was 50 with operator '<', or a string OID value did not equal the expected literal.","commonSituations":"Operator/operand type mismatch (string vs number comparison), wrong jsonPath for the SNMP scalar (SNMP values are not JSON — jsonPath is often left empty and the operator compares the raw value), expectedValue entered with wrong units or formatting, or the monitored condition genuinely degraded (disk full, service down) and the monitor correctly flagged it.","solutions":["Inspect heartbeat.msg of the passing branch to see the actual response value and confirm it is the type/format you expect.","Align jsonPathOperator and expectedValue to the real SNMP value type (use a numeric operator only when the value is numeric).","Leave jsonPath empty for scalar SNMP values so evaluateJsonQuery compares the raw value directly.","If the comparison legitimately fails, treat this as a correct DOWN signal and adjust the expectedValue threshold rather than the code."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"function coerceExpected(value, expected, operator) {\n  if ([\"<\", \"<=\", \">\", \">=\"].includes(operator)) {\n    return { value: Number(value), expected: Number(expected) };\n  }\n  return { value, expected };\n}","typeGuard":"function isNumericOp(op) { return [\"<\", \"<=\", \">\", \">=\"].includes(op); }","tryCatchPattern":"// This is an expected DOWN path — surface it, don't crash the runner.\nif (!status) { heartbeat.status = DOWN; heartbeat.msg = `compare failed: ${response} ${op} ${expected}`; }","preventionTips":["Leave jsonPath empty for scalar SNMP values.","Match the operator to the value type (numeric op only for numbers).","Log the actual response value during onboarding to confirm the expectedValue units."],"tags":["snmp","json-query","predicate","monitoring"],"backgroundTag":null,"analyzedSha":"6b5ea0155793e666666745fb8d6fef1e829543a2","analyzedAt":"2026-08-12T23:42:12.959Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}