{"record":{"id":"4b0e35f7f0981b9c","repo":"louislam/uptime-kuma","slug":"queried-value-not-found","errorCode":null,"errorMessage":"Queried value not found.","messagePattern":"Queried value not found\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"server/monitor-types/mongodb.js","lineNumber":32,"sourceCode":"        if (monitor.databaseQuery) {\n            command = JSON.parse(monitor.databaseQuery);\n        }\n\n        let result = await this.runMongodbCommand(monitor.databaseConnectionString, command);\n\n        if (result[\"ok\"] !== 1) {\n            throw new Error(\"MongoDB command failed\");\n        } else {\n            heartbeat.msg = \"Command executed successfully\";\n        }\n\n        if (monitor.jsonPath) {\n            let expression = jsonata(monitor.jsonPath);\n            result = await expression.evaluate(result);\n            if (result) {\n                heartbeat.msg = \"Command executed successfully and the jsonata expression produces a result.\";\n            } else {\n                throw new Error(\"Queried value not found.\");\n            }\n        }\n\n        if (monitor.expectedValue) {\n            if (result.toString() === monitor.expectedValue) {\n                heartbeat.msg = \"Command executed successfully and expected value was found\";\n            } else {\n                throw new Error(\n                    \"Query executed, but value is not equal to expected value, value was: [\" +\n                        JSON.stringify(result) +\n                        \"]\"\n                );\n            }\n        }\n\n        heartbeat.status = UP;\n    }\n","sourceCodeStart":14,"sourceCodeEnd":50,"githubUrl":"https://github.com/louislam/uptime-kuma/blob/6b5ea0155793e666666745fb8d6fef1e829543a2/server/monitor-types/mongodb.js#L14-L50","documentation":"Thrown by the MongoDB monitor when monitor.jsonPath is set and the JSONata expression evaluates to a falsy value (null, undefined, empty). This means the path pointed at something that does not exist (or is empty) in the command result, so the query 'did not find' the value.","triggerScenarios":"monitor.jsonPath is truthy, expression.evaluate(result) returns a falsy value (null/undefined/''). E.g. jsonPath '$.connections.current' on a result that has no 'connections' field.","commonSituations":"jsonPath does not match the actual shape of the command's result object, the field is genuinely null/empty at this moment, or the jsonPath syntax is wrong for JSONata.","solutions":["Run the same command and inspect the full result object to find the correct path","Test the JSONata expression against a sample result in the JSONata playground","Confirm the field is populated at check time (not transiently empty)","If you only need a value comparison, ensure jsonPath resolves to a non-empty value"],"exampleFix":"// before: path does not exist on result\nmonitor.jsonPath = \"$.opcounters.query\"; // field absent\n// after: correct field from the command result\nmonitor.jsonPath = \"$.opcounters.query\"; // after confirming via db.command() output","handlingStrategy":"validation","validationCode":"// Validate JSONata expression syntax before running\nif (monitor.jsonPath) {\n    try { jsonata(monitor.jsonPath); } catch {\n        throw new Error(\"Invalid JSONata jsonPath: \" + monitor.jsonPath);\n    }\n}","typeGuard":null,"tryCatchPattern":"if (monitor.jsonPath) {\n    const expression = jsonata(monitor.jsonPath);\n    result = await expression.evaluate(result);\n    if (!result) throw new Error(\"Queried value not found.\");\n}","preventionTips":["Inspect the full command result once to derive the correct JSONata path","Test the expression in the JSONata playground against a sample result","Prefer paths that are always present to avoid transient false negatives"],"tags":["mongodb","jsonata","jsonpath","config"],"backgroundTag":null,"analyzedSha":"6b5ea0155793e666666745fb8d6fef1e829543a2","analyzedAt":"2026-08-12T23:42:12.959Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}