louislam/uptime-kuma · error · Error

Query returned no results

Error message

Query returned no results

What it means

Thrown by oracledbQuerySingleValue when result.rows is absent or empty. Only reached when conditions are enabled, since the monitor then expects a scalar to feed the condition evaluator. An empty result means there is no value to compare.

Source

Thrown at server/monitor-types/oracledb.js:127

     * @param {string} query The query to execute
     * @param {string} username Oracle DB username
     * @param {string} password Oracle DB password
     * @returns {Promise<any>} Single value from the first column of the first row
     */
    async oracledbQuerySingleValue(connectionString, query, username, password) {
        let connection;
        try {
            connection = await oracledb.getConnection({
                connectString: connectionString,
                user: username,
                password: password,
            });
            const result = await connection.execute(query, [], {
                outFormat: oracledb.OUT_FORMAT_OBJECT,
            });

            if (!result.rows || result.rows.length === 0) {
                throw new Error("Query returned no results");
            }

            if (result.rows.length > 1) {
                throw new Error("Multiple values were found, expected only one value");
            }

            const firstRow = result.rows[0];
            const columnNames = Object.keys(firstRow);

            if (columnNames.length > 1) {
                throw new Error("Multiple columns were found, expected only one value");
            }

            return firstRow[columnNames[0]];
        } catch (error) {
            log.debug(this.name, "Error caught in the query execution.", error.message);
            throw error;
        } finally {

View on GitHub (pinned to 6b5ea01557)

Solutions

  1. Run the query in SQL Developer/SQLcl as the monitor user and confirm exactly one row returns.
  2. If no-row is legitimate, rewrite with a guaranteed scalar: SELECT NVL((SELECT ... ),0) FROM dual.
  3. Loosen/fix the WHERE clause and ensure correct schema/PDB.
  4. Disable conditions if only connection/row-count semantics are needed.

Example fix

-- before: SELECT balance FROM accounts WHERE id=:id;   (id missing -> 0 rows)
-- after:  SELECT NVL((SELECT balance FROM accounts WHERE id=:id), -1) FROM dual;
Defensive patterns

Strategy: validation

Validate before calling

async function assertOracleSingleValue(connStr, query, user, pass) {
  const c = await oracledb.getConnection({ connectString: connStr, user, password: pass });
  try { const r = await c.execute(query, [], { outFormat: oracledb.OUT_FORMAT_OBJECT });
    if (!r.rows || r.rows.length === 0) throw new Error('0 rows');
    if (r.rows.length > 1) throw new Error('>1 row');
    if (Object.keys(r.rows[0]).length > 1) throw new Error('>1 column');
    return r.rows[0][Object.keys(r.rows[0])[0]]; }
  finally { await c.close(); }
}

Type guard

function isSingleValueRows(r) { return r?.rows?.length === 1 && Object.keys(r.rows[0]).length === 1; }

Prevention

When it happens

Trigger: monitor.conditions non-empty, connection.execute(query) resolves with result.rows.length === 0 (or null rows). Typical when a WHERE filters all rows, the object is in another schema, or the query targets the wrong PDB.

Common situations: WHERE too restrictive; table/view renamed; querying the CDB root for PDB-local data; environment missing the expected reference row; conditions enabled on a row-count-style query.

Related errors


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