{"record":{"id":"161f38b1745d3147","repo":"RocketChat/Rocket.Chat","slug":"error-invalid-webhook-response","errorCode":"error-invalid-webhook-response","errorMessage":"error-invalid-webhook-response","messagePattern":"error-invalid-webhook-response","errorType":"exception","errorClass":"Error","httpStatus":400,"severity":"error","filePath":"apps/meteor/server/api/v1/omnichannel/webhooks.ts","lineNumber":91,"sourceCode":"\n\t\t\tif (!webhookUrl) {\n\t\t\t\treturn API.v1.failure('Webhook_URL_not_set');\n\t\t\t}\n\n\t\t\ttry {\n\t\t\t\tlogger.debug({ msg: 'Testing webhook', webhookUrl });\n\t\t\t\tconst request = await fetch(webhookUrl, options);\n\t\t\t\tconst response = await request.text();\n\n\t\t\t\tlogger.debug({ msg: 'Webhook response', response });\n\t\t\t\tif (request.status === 200) {\n\t\t\t\t\treturn API.v1.success();\n\t\t\t\t}\n\n\t\t\t\tthrow new Error('Invalid status code');\n\t\t\t} catch (error) {\n\t\t\t\tlogger.error({ msg: 'Error testing webhook', err: error });\n\t\t\t\tthrow new Error('error-invalid-webhook-response');\n\t\t\t}\n\t\t},\n\t},\n);\n","sourceCodeStart":73,"sourceCodeEnd":96,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/server/api/v1/omnichannel/webhooks.ts#L73-L96","documentation":"Catch-all thrown by POST /api/v1/livechat/webhook.test: any failure while POSTing the sample payload to Livechat_webhookUrl — DNS resolution failure, TLS error, timeout, oversized response (fetch size cap is 10MB), or the inner 'Invalid status code' for non-200 replies — is logged and re-thrown as error-invalid-webhook-response. The original cause is only visible in the server logs (WebhookTest logger.error), not in the API response.","triggerScenarios":"POST /api/v1/livechat/webhook.test with Livechat_webhookUrl unreachable (wrong DNS, expired cert, firewall blocking the server's egress), a URL that returns non-200, or a handler that hangs until the fetch times out. If Livechat_webhookUrl is unset you get 'Webhook_URL_not_set' instead — this error implies a URL was configured.","commonSituations":"Webhook URL from a local tunnel (ngrok-style) that expired; self-signed certificate on the receiver; server egress restricted so it can't reach an internal service; receiver slow to respond and connection reset mid-test.","solutions":["From the Rocket.Chat server host (not your laptop), curl -i the Livechat_webhookUrl with the sample payload — this reproduces DNS/TLS/egress problems the API test hides","Check the server logs: the WebhookTest logger records the exact underlying error (ENOTFOUND, CERT_HAS_EXPIRED, socket hang up, ...)","If curl from the server works but the test still fails, compare response status and size — must be 200 and under the 10MB read cap"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"import { lookup } from 'node:dns/promises';\n// cheap pre-flight from the Rocket.Chat host's network position\nawait lookup(new URL(webhookUrl).hostname); // throws ENOTFOUND early instead of inside webhook.test","typeGuard":null,"tryCatchPattern":"wrap webhook.test in a retry with capped backoff (e.g. 3 attempts, 5s apart) but only for transient causes — re-run after confirming DNS/TLS from the server host; a deterministic non-200 receiver will fail every time, so fix the endpoint instead of retrying.","preventionTips":["Keep an uptime check on the webhook endpoint — the omnichannel integration fails silently between tests","Watch certificate expiry on the receiver","Confirm the server's egress can reach internal webhook hosts (firewall rules)","Keep responses under 10MB"],"tags":["omnichannel","webhook","integration","network","livechat"],"backgroundTag":"webhook-request-failed","analyzedSha":"b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0","analyzedAt":"2026-08-18T15:26:39.429Z","contentChangedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}