louislam/uptime-kuma · error · Error
Message received but value is not equal to expected value, v
Error message
Message received but value is not equal to expected value, value was: [${result}] What it means
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.
Source
Thrown at server/monitor-types/mqtt.js:86
}
/**
* Check using JSONata query
* @param {object} monitor Monitor object
* @param {object} heartbeat Heartbeat object
* @param {string} receivedMessage Received MQTT message
* @returns {Promise<void>}
*/
async checkJsonQuery(monitor, heartbeat, receivedMessage) {
const parsedMessage = JSON.parse(receivedMessage);
const expression = jsonata(monitor.jsonPath);
const result = await expression.evaluate(parsedMessage);
if (result?.toString() === monitor.expectedValue) {
heartbeat.msg = "Message received, expected value is found";
heartbeat.status = UP;
} else {
throw new Error("Message received but value is not equal to expected value, value was: [" + result + "]");
}
}
/**
* Check using conditions system
* @param {object} monitor Monitor object
* @param {object} heartbeat Heartbeat object
* @param {string} messageTopic Received MQTT topic
* @param {string} receivedMessage Received MQTT message
* @param {ConditionExpressionGroup} conditions Parsed conditions
* @returns {Promise<void>}
*/
async checkConditions(monitor, heartbeat, messageTopic, receivedMessage, conditions) {
let jsonValue = null;
// Parse JSON and extract value if jsonPath is defined
if (monitor.jsonPath) {
try {View on GitHub (pinned to 6b5ea01557)
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.
Example fix
// before: jsonPath='$.temp', expectedValue=22 (payload {"temp":22.5})
// after: jsonPath='$.temp', expectedValue='22.5'
// or use conditions: json_value >= 22 AND json_value <= 23 Defensive patterns
Strategy: try-catch
Validate before calling
const jsonata = require('jsonata');
function dryRunJsonQuery(payload, jsonPath, expectedValue) {
const v = (await jsonata(jsonPath).evaluate(JSON.parse(payload)))?.toString();
return v === expectedValue;
} Type guard
function hasJsonQueryConfig(m) { return m.mqttCheckType === 'json-query' && typeof m.jsonPath === 'string' && typeof m.expectedValue === 'string'; } Try / catch
try { await mqttMonitor.checkJsonQuery(monitor, heartbeat, msg); }
catch (e) {
if (/value is not equal to expected value/.test(e.message)) { heartbeat.status = DOWN; heartbeat.msg = e.message; }
else if (e instanceof SyntaxError) { heartbeat.status = DOWN; heartbeat.msg = 'Invalid JSON payload'; }
else throw e;
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Empty or undefined response. Check query syntax and response
- JSON query returned the array ${truncatedResponse}, but a pr
- The post-JSON query evaluated response from the server is of
- Invalid condition ${jsonPathOperator}
- Query evaluation returned undefined. Check query syntax and
AI-assisted analysis of louislam/uptime-kuma@6b5ea01557 (2026-08-12).
Data as JSON: /api/errors/7dd4cc5721aa6dd8.
Report an issue: GitHub.