{"record":{"id":"4c8c56eeae6cdb48","repo":"louislam/uptime-kuma","slug":"conditions-not-met-topic-messagetopic-messa","errorCode":null,"errorMessage":"Conditions not met - Topic: ${messageTopic}; Message: ${receivedMessage}","messagePattern":"Conditions not met - Topic: (.+?); Message: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"server/monitor-types/mqtt.js","lineNumber":125,"sourceCode":"                jsonValue = await expression.evaluate(parsedMessage);\n            } catch (e) {\n                // JSON parsing failed, jsonValue remains null\n            }\n        }\n\n        const conditionData = {\n            topic: messageTopic,\n            message: receivedMessage,\n            json_value: jsonValue?.toString() ?? \"\",\n        };\n\n        const conditionsResult = evaluateExpressionGroup(conditions, conditionData);\n\n        if (conditionsResult) {\n            heartbeat.msg = `Topic: ${messageTopic}; Message: ${receivedMessage}`;\n            heartbeat.status = UP;\n        } else {\n            throw new Error(`Conditions not met - Topic: ${messageTopic}; Message: ${receivedMessage}`);\n        }\n    }\n\n    /**\n     * Connect to MQTT Broker, subscribe to topic and receive message as String\n     * @param {string} hostname Hostname / address of machine to test\n     * @param {string} topic MQTT topic\n     * @param {object} options MQTT options. Contains port, username,\n     * password, websocketPath and interval (interval defaults to 20)\n     * @returns {Promise<string>} Received MQTT message\n     */\n    mqttAsync(hostname, topic, options = {}) {\n        return new Promise((resolve, reject) => {\n            const { port, username, password, websocketPath, interval = 20 } = options;\n\n            // Adds MQTT protocol to the hostname if not already present\n            if (!/^(?:http|mqtt|ws)s?:\\/\\//.test(hostname)) {\n                hostname = \"mqtt://\" + hostname;","sourceCodeStart":107,"sourceCodeEnd":143,"githubUrl":"https://github.com/louislam/uptime-kuma/blob/6b5ea0155793e666666745fb8d6fef1e829543a2/server/monitor-types/mqtt.js#L107-L143","documentation":"Thrown by MqttMonitorType.checkConditions when evaluateExpressionGroup returns false for the condition data {topic, message, json_value}. This is the conditions-system path; the message body and topic are exposed to user-defined operators, and json_value is the stringified JSONata result (empty string when jsonPath is unset or JSON parsing failed silently).","triggerScenarios":"monitor.conditions parses to a non-empty ConditionExpressionGroup (hasConditions true), mqttAsync resolves with a message, and the evaluated group over {topic, message, json_value} is false. Also fires when monitor.jsonPath is set but receivedMessage is not valid JSON — the inner try/catch swallows the parse error, json_value becomes '', and conditions referencing json_value then fail.","commonSituations":"Condition uses the wrong variable name (e.g. 'value' instead of 'json_value'); operator chosen expects a number but json_value is empty because JSON parse failed; regex/case-sensitive string operator against a differently-cased payload; jsonPath typo producing empty json_value.","solutions":["Confirm the published payload is valid JSON when monitor.jsonPath is set (a non-JSON payload silently blanks json_value).","Verify the condition references only exposed variables: 'topic', 'message', 'json_value'.","Test the condition expression against the actual topic/message/json_value triple using evaluateExpressionGroup directly.","If matching raw text, use the 'message' variable with the right string operator; switch json_value conditions to 'message' contains if JSON is unreliable."],"exampleFix":"// before: condition variable='value' operator='==' value='ON'  (no such variable)\n// after:  condition variable='json_value' operator='==' value='ON'\n// and ensure payload is JSON {\"state\":\"ON\"} so json_value is populated","handlingStrategy":"try-catch","validationCode":"const { evaluateExpressionGroup } = require('../server/monitor-conditions/evaluator');\nfunction dryRunConditions(group, topic, message, jsonValue) {\n  return evaluateExpressionGroup(group, { topic, message, json_value: jsonValue ?? '' });\n}","typeGuard":"function conditionsExposeOnlyAllowedVars(group) {\n  const allowed = new Set(['topic','message','json_value']);\n  return group.children.every(c => allowed.has(c.variable));\n}","tryCatchPattern":"try { await mqttMonitor.checkConditions(monitor, heartbeat, topic, msg, group); }\ncatch (e) { if (/Conditions not met/.test(e.message)) { heartbeat.status = DOWN; heartbeat.msg = e.message; } else throw e; }","preventionTips":["Only reference 'topic', 'message', 'json_value' in MQTT conditions.","Ensure the payload is valid JSON whenever monitor.jsonPath is set, or json_value silently becomes empty.","Unit-test the condition expression against sample data."],"tags":["mqtt","conditions","monitor","uptime-kuma"],"backgroundTag":null,"analyzedSha":"6b5ea0155793e666666745fb8d6fef1e829543a2","analyzedAt":"2026-08-12T23:42:12.959Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}