RocketChat / RocketChat/Rocket.Chat

Response of Outgoing Webhook triggers exception

Open
#23,699 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
46.1k
Forks
13.9k
Avg merge
3d 3h
Merged PRs (30d)
130

Description

Description:

Response of outgoing webhooks is not posted to room.
We did an upgrade to 4.1.2 recently. from that last version of 3.x

Steps to reproduce:

1.Have an Outgoing Webhook. In our example we have an Integration called "UBot" which responds on the trigger '?'
That will be posted to a small script, which returns the output of the shell command given right after '?'
2. do a ?dig test.de which should give us the output of the dig command.
Hoewever, the returned response triggers an exception:

{"level":20,"time":"2021-11-12T08:26:37.265Z","pid":10,"hostname":"3d7d4c3fe47e","name":"Integrations","section":"Outgoing WebHook","msg":"Found a room for UBot which is: undefined with a type of d"}

The full log generated:

{"level":20,"time":"2021-11-12T08:26:37.262Z","pid":10,"hostname":"3d7d4c3fe47e","name":"Integrations","section":"Outgoing WebHook","msg":"Script method \"process_outgoing_response\" result of the Integration \"UBot\" is:","result":{"content":{"text":"\n; <<>> DiG 9.11.5-P4-5.1+deb10u2-Debian <<>> test.de\n;; global options: +cmd\n;; Got answer:\n;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 12336\n;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 3, ADDITIONAL: 7\n\n;; OPT PSEUDOSECTION:\n; EDNS: version: 0, flags:; udp: 4096\n;; QUESTION SECTION:\n;test.de.\t\t\tIN\tA\n\n;; ANSWER SECTION:\ntest.de.\t\t516\tIN\tA\t20.82.65.183\n\n;; AUTHORITY SECTION:\ntest.de.\t\t85688\tIN\tNS\tdns.iwelt-ag.net.\ntest.de.\t\t85688\tIN\tNS\tdns2.iwelt-ag.net.\ntest.de.\t\t85688\tIN\tNS\tdns3.iwelt-ag.de.\n\n;; ADDITIONAL SECTION:\ndns.iwelt-ag.net.\t96\tIN\tA\t82.212.222.10\ndns.iwelt-ag.net.\t96\tIN\tAAAA\t2a00:cb0:1::10\ndns2.iwelt-ag.net.\t96\tIN\tA\t82.212.255.10\ndns2.iwelt-ag.net.\t96\tIN\tAAAA\t2a00:cb0:8001::10\ndns3.iwelt-ag.de.\t29744\tIN\tA\t85.236.41.196\ndns3.iwelt-ag.de.\t29744\tIN\tAAAA\t2001:4178:2:1328::10\n\n;; Query time: 1 msec\n;; SERVER: 37.208.104.6#53(37.208.104.6)\n;; WHEN: Fri Nov 12 09:26:37 CET 2021\n;; MSG SIZE rcvd: 261\n\n","parseUrls":false}}} {"level":20,"time":"2021-11-12T08:26:37.265Z","pid":10,"hostname":"3d7d4c3fe47e","name":"Integrations","section":"Outgoing WebHook","msg":"Found a room for UBot which is: undefined with a type of d"} Exception in callback of async function: Error: error-not-allowed at app/authorization/server/functions/canSendMessage.js:19:9 at /app/bundle/programs/server/npm/node_modules/meteor/promise/node_modules/meteor-promise/fiber_pool.js:43:40 => awaited here: at Function.Promise.await (/app/bundle/programs/server/npm/node_modules/meteor/promise/node_modules/meteor-promise/promise_server.js:56:12) at validateRoomMessagePermissions (app/authorization/server/functions/canSendMessage.js:48:101) at processWebhookMessage (app/lib/server/functions/processWebhookMessage.js:82:3) at RocketChatIntegrationHandler.sendMessage (app/integrations/server/lib/triggerHandler.js:195:13) at app/integrations/server/lib/triggerHandler.js:695:33 at runWithEnvironment (packages/meteor.js:1286:24)

  • Version of Rocket.Chat Server: 4.1.2
  • Operating System: Debian 10
  • Deployment Method: docker
  • Number of Running Instances: 1

Any help would be nice

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with app/integrations/server/lib/triggerHandler.js and trace processWebhookMessage in app/lib/server/functions/processWebhookMessage.js into canSendMessage.js. Reproduce the outgoing webhook with the response shown in the issue, then verify that the response is posted to the originating room without the error-not-allowed exception.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.