{"record":{"id":"c25c3044272c4164","repo":"louislam/uptime-kuma","slug":"heartbeat-msg-but-keyword-is-keywordfound","errorCode":null,"errorMessage":"${heartbeat.msg}, but keyword is ${keywordFound ? \"present\" : \"not\"} in [${data}]","messagePattern":"(.+?), but keyword is (.+?) in \\[(.+?)\\]","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"server/monitor-types/globalping.js","lineNumber":399,"sourceCode":"\n    /**\n     * Handles keyword search for HTTP monitors.\n     * @param {Monitor} monitor - The monitor object.\n     * @param {Heartbeat} heartbeat - The heartbeat object.\n     * @param {Result} result - The result object.\n     * @param {Probe} probe - The probe object.\n     * @returns {Promise<void>}\n     */\n    async handleKeywordForHTTP(monitor, heartbeat, result, probe) {\n        let data = result.rawOutput;\n        let keywordFound = data.includes(monitor.keyword);\n\n        if (keywordFound === Boolean(monitor.invertKeyword)) {\n            data = data.replace(/<[^>]*>?|[\\n\\r]|\\s+/gm, \" \").trim();\n            if (data.length > 50) {\n                data = data.substring(0, 47) + \"...\";\n            }\n            throw new Error(\n                heartbeat.msg + \", but keyword is \" + (keywordFound ? \"present\" : \"not\") + \" in [\" + data + \"]\"\n            );\n        }\n\n        heartbeat.msg += \", keyword \" + (keywordFound ? \"is\" : \"not\") + \" found\";\n        heartbeat.status = UP;\n    }\n\n    /**\n     * Handles JSON query for HTTP monitors.\n     * @param {Monitor} monitor - The monitor object.\n     * @param {Heartbeat} heartbeat - The heartbeat object.\n     * @param {Result} result - The result object.\n     * @param {Probe} probe - The probe object.\n     * @returns {Promise<void>} A promise that resolves when the JSON query is handled.\n     */\n    async handleJSONQueryForHTTP(monitor, heartbeat, result, probe) {\n        const { status, response } = await evaluateJsonQuery(","sourceCodeStart":381,"sourceCodeEnd":417,"githubUrl":"https://github.com/louislam/uptime-kuma/blob/6b5ea0155793e666666745fb8d6fef1e829543a2/server/monitor-types/globalping.js#L381-L417","documentation":"Thrown by handleKeywordForHTTP when keyword presence does not match the invert setting. With invertKeyword off, the keyword must be present; with invert on, it must be absent. The response is HTML/whitespace-stripped and truncated to 47 chars before being included so the message stays readable.","triggerScenarios":"keywordFound === Boolean(monitor.invertKeyword). If invert is false and keyword absent -> throw 'not present'; if invert is true and keyword present -> throw 'present'. This is the classic keyword-mismatch path for Globalping HTTP keyword monitors.","commonSituations":"Target page content changed so the keyword no longer appears, the keyword was set against transient content, invertKeyword is accidentally enabled/disabled, or the keyword matches part of HTML markup that gets stripped before the check re-runs.","solutions":["Open the target URL and confirm whether the keyword actually appears in the response body","Re-check the invertKeyword toggle — invert means the monitor is UP when the keyword is ABSENT","Pick a stable, unique keyword that survives layout changes","Remember the displayed response is stripped of tags/whitespace and truncated to ~47 chars"],"exampleFix":"// before: invert on, keyword appears -> DOWN\nmonitor.invertKeyword = true;\nmonitor.keyword = \"maintenance\";\n// after: invert off when you want the keyword to be present\nmonitor.invertKeyword = false;","handlingStrategy":"validation","validationCode":"// Confirm keyword semantics before running\nif (!monitor.keyword || monitor.keyword.length === 0) {\n    throw new Error(\"HTTP keyword monitor has no keyword set\");\n}\n// invertKeyword: when true, monitor is UP only if keyword is ABSENT\nconst expectPresent = !monitor.invertKeyword;","typeGuard":null,"tryCatchPattern":"// The thrown message already truncates the body; preserve it for alerting\nif (keywordFound === Boolean(monitor.invertKeyword)) {\n    throw new Error(heartbeat.msg + \", but keyword is \" + (keywordFound ? \"present\" : \"not\") + \" in [\" + data + \"]\");\n}","preventionTips":["Choose a stable, unique keyword unlikely to change with layout updates","Double-check the invert toggle semantics before saving","Periodically verify the keyword still appears in the live response"],"tags":["globalping","http","keyword","config"],"backgroundTag":null,"analyzedSha":"6b5ea0155793e666666745fb8d6fef1e829543a2","analyzedAt":"2026-08-12T23:42:12.959Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}