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 MssqlMonitorType.check when conditions are configured and the single-value query result, coerced to String, does not satisfy evaluateExpressionGroup({result: String(result)}). The condition system is given exactly one variable named 'result', so any condition referencing another variable will always be false.
Source
Thrown at server/monitor-types/mssql.js:39
// No query provided by user, use SELECT 1
if (!query || (typeof query === "string" && query.trim() === "")) {
query = "SELECT 1";
}
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.mssqlQuerySingleValue(monitor.databaseConnectionString, query);
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.mssqlQuery(monitor.databaseConnectionString, query);
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 SSMS/Azure Data Studio and note the precise scalar value (including decimals/formatting) the monitor will see.
- Ensure the condition references the 'result' variable; no other variable is exposed on this monitor type.
- Use numeric operators (>, <, between) rather than '==' when the column is numeric, to avoid String() formatting mismatches like '1' vs '1.00'.
- Cast/round the value in the SELECT (e.g. SELECT CAST(col AS int) or ROUND(col,2)) so it matches the condition literal deterministically.
Example fix
-- before: SELECT AVG(price) FROM orders (returns 12.340000) -- condition: result == '12.34' -> fails -- after: SELECT ROUND(AVG(price),2) FROM orders; -- condition: result >= 12 and result <= 13
Defensive patterns
Strategy: try-catch
Validate before calling
const scalar = await mssqlMonitor.mssqlQuerySingleValue(connStr, query);
const ok = evaluateExpressionGroup(group, { result: String(scalar) });
if (!ok) { /* adjust query or condition before enabling */ } Type guard
function conditionUsesResultVar(group) { return group.children.every(c => c.variable === 'result'); } Try / catch
try { await mssqlMonitor.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
- Always SELECT a single, deterministic scalar and round/cast it.
- Reference only the 'result' variable in MSSQL conditions.
- Use numeric range operators for numeric columns.
When it happens
Trigger: monitor.conditions has children, mssqlQuerySingleValue returns a scalar, and evaluateExpressionGroup over {result: String(result)} is false. Common when the condition expects a numeric operator but 'result' is a stringified value like '1.0000', or when threshold/operator semantics do not match the actual value.
Common situations: Condition uses operator '==' against a formatted number ('1' vs '1.00'); condition references a variable other than 'result'; SQL returns a value outside the expected range; String() coercion of dates/decimals differs from the literal in the condition.
Related errors
- Database connection/query failed: ${error.message}
- Query returned no results
- Multiple values were found, expected only one value
- Multiple columns were found, expected only one value
- Query result did not meet the specified conditions (${result
AI-assisted analysis of louislam/uptime-kuma@6b5ea01557 (2026-08-12).
Data as JSON: /api/errors/ddcc8c454c7ccea3.
Report an issue: GitHub.