louislam/uptime-kuma · error · Error
Query result did not meet the specified conditions (${result
Error message
Query result did not meet the specified conditions (${result}) What it means
Thrown by MysqlMonitorType.check when conditions are configured and the single-value result does not satisfy evaluateExpressionGroup({result: String(result)}). Identical semantics to the MSSQL variant: only the 'result' variable is exposed, and the value is stringified before comparison.
Source
Thrown at server/monitor-types/mysql.js:42
// Use `radius_password` as `password` field for backwards compatibility
// TODO: rename `radius_password` to `password` later for general use
const password = monitor.radiusPassword;
const conditions = monitor.conditions ? ConditionExpressionGroup.fromMonitor(monitor) : null;
const hasConditions = conditions && conditions.children && conditions.children.length > 0;
const startTime = dayjs().valueOf();
try {
if (hasConditions) {
// When conditions are enabled, expect a single value result
const result = await this.mysqlQuerySingleValue(monitor.databaseConnectionString, query, password);
heartbeat.ping = dayjs().valueOf() - startTime;
const conditionsResult = evaluateExpressionGroup(conditions, { result: String(result) });
if (!conditionsResult) {
throw new Error(`Query result did not meet the specified conditions (${result})`);
}
heartbeat.status = UP;
heartbeat.msg = "Query did meet specified conditions";
} else {
// Backwards compatible: just check connection and return row count
const result = await this.mysqlQuery(monitor.databaseConnectionString, query, password);
heartbeat.ping = dayjs().valueOf() - startTime;
heartbeat.status = UP;
heartbeat.msg = result;
}
} catch (error) {
heartbeat.ping = dayjs().valueOf() - startTime;
// Re-throw condition errors as-is, wrap database errors
if (error.message.includes("did not meet the specified conditions")) {
throw error;
}
throw new Error(`Database connection/query failed: ${error.message}`);View on GitHub (pinned to 6b5ea01557)
Solutions
- Run the exact query in the mysql CLI from the monitor host and inspect the value's string form.
- Condition must reference 'result'; use numeric operators for numeric columns.
- Cast in SQL (CAST(col AS CHAR), CAST(col AS SIGNED), ROUND(col,n)) so the stringified value matches the condition literal.
- Validate with a BETWEEN/range condition instead of strict equality for floats.
Example fix
-- before: SELECT AVG(price) FROM orders; -> '12.3400' -- after: SELECT ROUND(AVG(price),2) FROM orders; -> '12.34' -- condition: result >= 12 and result <= 13
Defensive patterns
Strategy: try-catch
Validate before calling
const scalar = await mysqlMonitor.mysqlQuerySingleValue(connStr, query, password);
const ok = evaluateExpressionGroup(group, { result: String(scalar) }); Type guard
function conditionUsesResultVar(group) { return group.children.every(c => c.variable === 'result'); } Try / catch
try { await mysqlMonitor.check(monitor, heartbeat, server); }
catch (e) { if (/did not meet the specified conditions/.test(e.message)) { heartbeat.status = DOWN; heartbeat.msg = e.message; } else throw e; } Prevention
- Cast/round in SQL (CAST(... AS CHAR), ROUND) so the stringified value is deterministic.
- Reference only 'result'; use numeric operators for numeric columns.
- Beware DECIMAL trailing zeros and BIT/TINYINT(1) coercion in MySQL.
When it happens
Trigger: monitor.conditions has children, mysqlQuerySingleValue returns a scalar, and evaluateExpressionGroup over {result: String(result)} is false. Mismatches arise from MySQL's type formatting (DECIMAL as '12.30', BIT as Buffer, TINYINT(1) as 0/1, JSON values).
Common situations: DECIMAL columns returning trailing zeros; BIT(1) returned as a Buffer that stringifies oddly; datetime formatted with locale; condition references wrong variable; condition literal doesn't match MySQL's string coercion.
Related errors
- Database connection/query failed: ${error.message}
- Query result did not meet the specified conditions (${result
- Query result did not meet the specified conditions (${result
- Conditions not met - Topic: ${messageTopic}; Message: ${rece
- Database connection/query failed: ${error.message}
AI-assisted analysis of louislam/uptime-kuma@6b5ea01557 (2026-08-12).
Data as JSON: /api/errors/16f8d95d4bdcdbf9.
Report an issue: GitHub.