{"record":{"id":"7dd4cc5721aa6dd8","repo":"louislam/uptime-kuma","slug":"message-received-but-value-is-not-equal-to-expecte","errorCode":null,"errorMessage":"Message received but value is not equal to expected value, value was: [${result}]","messagePattern":"Message received but value is not equal to expected value, value was: \\[(.+?)\\]","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"server/monitor-types/mqtt.js","lineNumber":86,"sourceCode":"    }\n\n    /**\n     * Check using JSONata query\n     * @param {object} monitor Monitor object\n     * @param {object} heartbeat Heartbeat object\n     * @param {string} receivedMessage Received MQTT message\n     * @returns {Promise<void>}\n     */\n    async checkJsonQuery(monitor, heartbeat, receivedMessage) {\n        const parsedMessage = JSON.parse(receivedMessage);\n        const expression = jsonata(monitor.jsonPath);\n        const result = await expression.evaluate(parsedMessage);\n\n        if (result?.toString() === monitor.expectedValue) {\n            heartbeat.msg = \"Message received, expected value is found\";\n            heartbeat.status = UP;\n        } else {\n            throw new Error(\"Message received but value is not equal to expected value, value was: [\" + result + \"]\");\n        }\n    }\n\n    /**\n     * Check using conditions system\n     * @param {object} monitor Monitor object\n     * @param {object} heartbeat Heartbeat object\n     * @param {string} messageTopic Received MQTT topic\n     * @param {string} receivedMessage Received MQTT message\n     * @param {ConditionExpressionGroup} conditions Parsed conditions\n     * @returns {Promise<void>}\n     */\n    async checkConditions(monitor, heartbeat, messageTopic, receivedMessage, conditions) {\n        let jsonValue = null;\n\n        // Parse JSON and extract value if jsonPath is defined\n        if (monitor.jsonPath) {\n            try {","sourceCodeStart":68,"sourceCodeEnd":104,"githubUrl":"https://github.com/louislam/uptime-kuma/blob/6b5ea0155793e666666745fb8d6fef1e829543a2/server/monitor-types/mqtt.js#L68-L104","documentation":"Thrown by MqttMonitorType.checkJsonQuery when the JSONata expression in monitor.jsonPath evaluates to a value whose string form does not strictly equal monitor.expectedValue. Because the comparison is result?.toString() === expectedValue, a missing path (result undefined) becomes the literal string 'undefined' and fails the same way. Note JSON.parse(receivedMessage) throwing is a separate, un-wrapped error that propagates from this method.","triggerScenarios":"mqttCheckType === 'json-query', receivedMessage parses as JSON, jsonata(monitor.jsonPath).evaluate(parsedMessage) resolves to a value, and String(result) !== monitor.expectedValue. Fires for type mismatches (number 1 vs string '1'), whitespace differences, undefined results from a non-matching path, or null results.","commonSituations":"expectedValue entered as a number but compared as string (or vice versa); jsonPath selects a nested field that does not exist in the actual payload; leading/trailing spaces in expectedValue; boolean true vs 'true'; locale/decimal formatting of numbers.","solutions":["Run the JSONata expression against a sample payload (e.g. jsonata REPL or https://try.jsonata.org) and copy the exact stringified result into expectedValue.","Ensure types align: enter expectedValue exactly as the expression stringifies it (numbers as numbers-as-strings, booleans as 'true'/'false').","If the path is optional or can be absent, add monitor.conditions with an 'exists' style operator instead of strict json-query equality.","Strip whitespace from expectedValue and confirm the published JSON has no extra fields changing the selected value."],"exampleFix":"// before: jsonPath='$.temp', expectedValue=22  (payload {\"temp\":22.5})\n// after: jsonPath='$.temp', expectedValue='22.5'\n// or use conditions: json_value >= 22 AND json_value <= 23","handlingStrategy":"try-catch","validationCode":"const jsonata = require('jsonata');\nfunction dryRunJsonQuery(payload, jsonPath, expectedValue) {\n  const v = (await jsonata(jsonPath).evaluate(JSON.parse(payload)))?.toString();\n  return v === expectedValue;\n}","typeGuard":"function hasJsonQueryConfig(m) { return m.mqttCheckType === 'json-query' && typeof m.jsonPath === 'string' && typeof m.expectedValue === 'string'; }","tryCatchPattern":"try { await mqttMonitor.checkJsonQuery(monitor, heartbeat, msg); }\ncatch (e) {\n  if (/value is not equal to expected value/.test(e.message)) { heartbeat.status = DOWN; heartbeat.msg = e.message; }\n  else if (e instanceof SyntaxError) { heartbeat.status = DOWN; heartbeat.msg = 'Invalid JSON payload'; }\n  else throw e;\n}","preventionTips":["Test jsonPath on try.jsonata.org against a real payload before saving.","Enter expectedValue exactly as the value stringifies (mind number vs string).","Use conditions with a numeric range instead of strict equality when the value is numeric."],"tags":["mqtt","jsonata","json-query","monitor","uptime-kuma"],"backgroundTag":null,"analyzedSha":"6b5ea0155793e666666745fb8d6fef1e829543a2","analyzedAt":"2026-08-12T23:42:12.959Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}