{"record":{"id":"d3faac3064ac44d0","repo":"louislam/uptime-kuma","slug":"error-evaluating-json-query-err-message-respo","errorCode":null,"errorMessage":"Error evaluating JSON query: ${err.message}. Response from server was: ${response}","messagePattern":"Error evaluating JSON query: (.+?)\\. Response from server was: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"src/util.ts","lineNumber":773,"sourceCode":"        const status = await expression.evaluate({\n            value: response.toString(),\n            expected: expectedValue.toString(),\n        });\n\n        if (status === undefined) {\n            throw new Error(\n                \"Query evaluation returned undefined. Check query syntax and the structure of the response data\"\n            );\n        }\n\n        return {\n            status, // The evaluation of the json query\n            response, // The response from the server or result from initial json-query evaluation\n        };\n    } catch (err: any) {\n        response = JSON.stringify(response); // Ensure the response is treated as a string for the console\n        response = response && response.length > 50 ? `${response.substring(0, 100)}… (truncated)` : response; // Truncate long responses to the console\n        throw new Error(`Error evaluating JSON query: ${err.message}. Response from server was: ${response}`);\n    }\n}\n\n// these types will have domain expiry support via the specified field\nexport const TYPES_WITH_DOMAIN_EXPIRY_SUPPORT_VIA_FIELD = {\n    http: \"url\",\n    keyword: \"url\",\n    \"json-query\": \"url\",\n    \"real-browser\": \"url\",\n    \"websocket-upgrade\": \"url\",\n    port: \"hostname\",\n    ping: \"hostname\",\n    \"grpc-keyword\": \"grpcUrl\",\n    dns: \"hostname\",\n    smtp: \"hostname\",\n    snmp: \"hostname\",\n    gamedig: \"hostname\",\n    steam: \"hostname\",","sourceCodeStart":755,"sourceCodeEnd":791,"githubUrl":"https://github.com/louislam/uptime-kuma/blob/6b5ea0155793e666666745fb8d6fef1e829543a2/src/util.ts#L755-L791","documentation":"Outer catch-all in evaluateJsonQuery(): any error thrown inside the function's try block (the inner [254]-[258] guards, a JSONata syntax/compile error, a thrown type error, etc.) is re-thrown wrapped with the server response (stringified, truncated to 100 chars with an ellipsis when long). It is the message the monitor ultimately surfaces in bean.msg / the UI, so its suffix always echoes the response payload that caused the failure.","triggerScenarios":"Any json-query monitor failure: malformed JSONata syntax in monitor.jsonPath (unbalanced brackets, unknown function), the inner [254] undefined/null, [255] array, [256] object, [257] bad operator, [258] undefined evaluation, or an unexpected exception from the jsonata engine. Essentially the unified error shape for the whole evaluation pipeline.","commonSituations":"First symptom a user sees for any broken json-query monitor; appears in the monitor's last-failure message and incident text; frequently confused with a network error because it includes the raw response — but it actually indicates query-time failure on a successful HTTP fetch.","solutions":["Read the inner message before 'Response from server was': it names the root cause (e.g. 'JSON query returned the array ...', 'Empty or undefined response...', 'Invalid condition ...')."],"exampleFix":"// before: monitor.jsonPath = \"$.items[\" (syntax error) -> wrapped -> \"Error evaluating JSON query: ...\"\n\n// after: validate the path in isolation before saving the monitor\nconst jsonata = require(\"jsonata\");\ntry {\n  await jsonata(monitor.jsonPath).evaluate(sampleResponseBody);\n} catch (e) {\n  alert(\"JSONata error: \" + e.message);\n  return;\n}","handlingStrategy":"try-catch","validationCode":"try { await jsonata(jsonPath).evaluate(sample); } catch (e) { throw new Error(\"JSONata parse/eval failed: \" + e.message); }","typeGuard":"const isCompilableJsonata = (p) => { try { jsonata(p); return true; } catch { return false; } };","tryCatchPattern":"try { await evaluateJsonQuery(data, path, op, expected); } catch (e) { const inner = e.message.split(\". Response from server\")[0]; setMonitorDown(inner); }","preventionTips":["Validate the JSONata path against a sample body before saving the monitor.","Read the inner message to find the root cause.","Map json-query errors to a DOWN status rather than surfacing the raw exception."],"tags":["json-query","jsonata","monitor","error-handling","typescript","uptime-kuma"],"backgroundTag":null,"analyzedSha":"6b5ea0155793e666666745fb8d6fef1e829543a2","analyzedAt":"2026-08-12T23:42:12.959Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}