Rocket.chat: Default intergration test example no longer works after upgrade to 2.1.0

Created on 3 Oct 2019  Â·  9Comments  Â·  Source: RocketChat/Rocket.Chat

Default intergration test example no longer works after upgrade to 2.1.0
curl -X POST -H 'Content-Type: application/json' --data '{"text":"Example message","attachments":[{"title":"Rocket.Chat","title_link":"https://rocket.chat","text":"Rocket.Chat, the best open source chat","image_url":"/images/integration-attachment-example.png","color":"#764FA5"}]}' https://REDACTED/hooks/REDACTED

Returns...
{"success":false,"error":"Invalid href value provided"}

Changing the image_url to a valid URL results in a successful post.

  • Version of Rocket.Chat Server: 2.1.0
  • Operating System: Ubuntu 16.04
  • Deployment Method: tar
  • Number of Running Instances: 3
  • DB Replicaset Oplog: Enable
  • NodeJS Version: v8.11.3
  • MongoDB Version: 3.6.14
stale

Most helpful comment

I've added "value" to error mesage in ValidLinkParam function (app.js in bundle), and got result:

{"success":false,"error":"Invalid href value provided: /images/integration-attachment-example.png"}

So the problem is that ValidLinkParam fails to validate relative URIs passed as image_url. They are provided by example calls in Integrations menu. I belive that relative URIs should be considered valid, or the example should generate absolute URL as "image_url:"

Workaround:

  • remove image_url parametr from json passed in curl, or
  • add https://servername/ part to its value

All 9 comments

Same on version 2.1.1. Also new integration created after migration (from 1.3.2) gives the same result.

server.js:208 API âž” debug POST: /hooks/xxx/yyy
server.js:208 Integrations âž” Incoming WebHook.info Post integration: build status general
server.js:208 Integrations âž” Incoming WebHook.debug @urlParams: { integrationId: 'AkB5s4aKCNKDgpZ3D',
  token: 'xxx' }
server.js:208 Integrations âž” Incoming WebHook.debug @bodyParams: { username: 'Jenkins',
  icon_url: 'https://jenkins.io/images/logos/jenkins/256.png',
  text: 'Example message',
  attachments: 
   [ { title: 'Tytuł',
       title_link: 'https://rocket.chat',
       text: 'xxx',
       image_url: '/images/integration-attachment-example.png',
       color: '#764FA5' } ] }
server.js:208 API âž” debug Failure { statusCode: 400,
  body: 
   { success: false,
     error: 'Invalid href value provided',
     stack: undefined } } 

I've added "value" to error mesage in ValidLinkParam function (app.js in bundle), and got result:

{"success":false,"error":"Invalid href value provided: /images/integration-attachment-example.png"}

So the problem is that ValidLinkParam fails to validate relative URIs passed as image_url. They are provided by example calls in Integrations menu. I belive that relative URIs should be considered valid, or the example should generate absolute URL as "image_url:"

Workaround:

  • remove image_url parametr from json passed in curl, or
  • add https://servername/ part to its value

+1 to workaround.
Also, make sure you have the right URL in configuration of integration. There is a little caveat, deleting "Optional" values does not work, you have to set the correct one once you set it anything else than empty string.

A similar error getting on our WHMCS RocketChat module. I have detailed the issue on this thread - https://github.com/RocketChat/Rocket.Chat/issues/15877

Can someone shed some light on this! :)

I have the same error with Grafana integration.
Usually, Grafana posts message like this:
{"attachments":[{"color":"#D63232","fallback":"[Alerting] Test notification","fields":[{"short":true,"title":"High value","value":100},{"short":true,"title":"Higher Value","value":200},{"short":false,"title":"Error message","value":"This is only a test"}],"footer":"Grafana v6.5.1","footer_icon":"https://grafana.com/assets/img/fav32.png", "image_url":"" ,"text":" Someone is testing the alert notification within grafana.","title":"[Alerting] Test notification","title_link":"https://monitor-eu-1.prod.overkiz.com/grafana/","ts":1575306326}],"parse":"full"}
The "image_url":"" causes this error message {"success":false,"error":"Invalid href value provided"}.

As a workaround, you can use this RocketChat script in the webhook definition:
class Script { process_incoming_request({ request }) { request.content.attachments.forEach(function (attachment) { attachment.image_url = null; }); return request; } }

It disables image in the message, and thus, avoid the {"success":false,"error":"Invalid href value provided"}

This issue is really problematic because also an empty image_url will bring rocketchat to reject an incoming webhook. This makes the API for handling incoming webhook really fragile.

Wouldn't it be more convenient when an empty or invalid image_url would be just ignored? Maybe with a warning on the logs? This way at least the webhook would work every time and the chance to miss imported notifications would be decreased.

thanks

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

This default curl example still doesn' t work. I have to delete image_url.

Was this page helpful?
0 / 5 - 0 ratings