louislam/uptime-kuma · error · Error

Query executed, but value is not equal to expected value, va

Error message

Query executed, but value is not equal to expected value, value was: [${JSON.stringify(result)}]

What it means

Thrown by the MongoDB monitor when monitor.expectedValue is set and the value (jsonPath result, or the whole command result if no jsonPath) does not equal expectedValue. The actual value is JSON-stringified into the message so you can see the mismatch. Runs after the jsonPath check, so 'result' here is either the jsonPath-evaluated value or the raw command result.

Source

Thrown at server/monitor-types/mongodb.js:40

        } else {
            heartbeat.msg = "Command executed successfully";
        }

        if (monitor.jsonPath) {
            let expression = jsonata(monitor.jsonPath);
            result = await expression.evaluate(result);
            if (result) {
                heartbeat.msg = "Command executed successfully and the jsonata expression produces a result.";
            } else {
                throw new Error("Queried value not found.");
            }
        }

        if (monitor.expectedValue) {
            if (result.toString() === monitor.expectedValue) {
                heartbeat.msg = "Command executed successfully and expected value was found";
            } else {
                throw new Error(
                    "Query executed, but value is not equal to expected value, value was: [" +
                        JSON.stringify(result) +
                        "]"
                );
            }
        }

        heartbeat.status = UP;
    }

    /**
     * Connect to and run MongoDB command on a MongoDB database
     * @param {string} connectionString The database connection string
     * @param {object} command MongoDB command to run on the database
     * @returns {Promise<(string[] | object[] | object)>} Response from server
     */
    async runMongodbCommand(connectionString, command) {
        let client = await MongoClient.connect(connectionString);

View on GitHub (pinned to 6b5ea01557)

Solutions

  1. Compare the echoed actual value (stringified) with expectedValue character-by-character
  2. Watch for type coercion: result.toString() compared to a string expectedValue — quote numbers
  3. If using jsonPath, confirm the evaluated value is what you expect before comparing
  4. Update expectedValue to match the current correct value if the metric legitimately changed

Example fix

// before: number vs string mismatch
monitor.expectedValue = 1; // result.toString() = "1", but JS "1" === 1 is false pre-stringify logic
// after: provide expectedValue as a string
monitor.expectedValue = "1";
Defensive patterns

Strategy: validation

Validate before calling

// Normalise expectedValue to string to match result.toString() comparison
if (monitor.expectedValue != null) {
    monitor.expectedValue = String(monitor.expectedValue);
}

Try / catch

if (monitor.expectedValue) {
    if (result.toString() === monitor.expectedValue) {
        heartbeat.msg = "Command executed successfully and expected value was found";
    } else {
        throw new Error("Query executed, but value is not equal to expected value, value was: [" + JSON.stringify(result) + "]");
    }
}

Prevention

When it happens

Trigger: monitor.expectedValue is truthy and result.toString() !== monitor.expectedValue. E.g. expected '1' but the field holds 1 (number) so the string comparison fails, or the value drifted from the expected literal.

Common situations: Type mismatch: result is a number but expectedValue is a string (toString vs strict equality), the monitored metric changed value, or expectedValue was never validated against real output.

Related errors


AI-assisted analysis of louislam/uptime-kuma@6b5ea01557 (2026-08-12). Data as JSON: /api/errors/c16124a30127efe4. Report an issue: GitHub.