louislam/uptime-kuma · error · Error
Multiple columns were found, expected only one value
Error message
Multiple columns were found, expected only one value
What it means
Thrown by mssqlQuerySingleValue when the first row exposes more than one column. The single-value path requires a 1-row x 1-column result so the condition evaluator receives an unambiguous scalar.
Source
Thrown at server/monitor-types/mssql.js:117
await pool.connect();
const result = await pool.request().query(query);
// Check if we have results
if (!result.recordset || result.recordset.length === 0) {
throw new Error("Query returned no results");
}
// Check if we have multiple rows
if (result.recordset.length > 1) {
throw new Error("Multiple values were found, expected only one value");
}
const firstRow = result.recordset[0];
const columnNames = Object.keys(firstRow);
// Check if we have multiple columns
if (columnNames.length > 1) {
throw new Error("Multiple columns were found, expected only one value");
}
// Return the single value from the first (and only) column
return firstRow[columnNames[0]];
} catch (err) {
log.debug("sqlserver", "Error caught in the query execution.", err.message);
throw err;
} finally {
if (pool) {
await pool.close();
}
}
}
}
module.exports = {
MssqlMonitorType,
};View on GitHub (pinned to 6b5ea01557)
Solutions
- Project exactly one column: SELECT <col> FROM ....
- If you need several fields, aggregate them into one expression (CONCAT, JSON, computed column).
- Drop unused columns from the SELECT list.
Example fix
-- before: SELECT id, balance FROM accounts WHERE id=@id; -- after: SELECT balance FROM accounts WHERE id=@id;
Defensive patterns
Strategy: validation
Validate before calling
function columnCountOfFirstRow(r) { return r?.recordset?.[0] ? Object.keys(r.recordset[0]).length : 0; } Type guard
function isSingleColumn(r) { return r?.recordset?.length>=1 && Object.keys(r.recordset[0]).length === 1; } Prevention
- Project exactly one column; never SELECT * with conditions enabled.
- Combine multiple fields into one expression (CONCAT/FOR JSON) if you need several.
When it happens
Trigger: monitor.conditions non-empty, exactly one row returned, but Object.keys(firstRow).length > 1. Happens with SELECT *, multi-column projections, or queries that include computed/identity columns.
Common situations: SELECT * used for convenience; query selects id plus the value column; a view returns extra metadata columns.
Related errors
- Query returned no results
- Multiple values were found, expected only one value
- Query result did not meet the specified conditions (${result
- Database connection/query failed: ${error.message}
- Query returned no results
AI-assisted analysis of louislam/uptime-kuma@6b5ea01557 (2026-08-12).
Data as JSON: /api/errors/88212fddeb70e47b.
Report an issue: GitHub.