coralproject / talk

A better commenting experience from Vox Media
https://coralproject.net
Other
1.89k stars 355 forks source link

Long comments trigger Slack error #4374

Closed rmens closed 9 months ago

rmens commented 11 months ago

We had a comment containing 1201 words (6130 characters) that wasn't posted to Slack to be moderated. The length seems to trigger an error:

{
  "name":"coral",
  "hostname":"xxxx",
  "pid":1,
  "level":50,
  "err":{
    "message":"slack returned non-200 status code: 400",
    "name":"Error",
    "stack":"SlackCoralEventListener.postMessage (src/core/server/events/listeners/slack/slack.ts:56:13)\nrunMicrotasks (<anonymous>)\nsrc/core/server/events/listeners/slack/slack.ts:136:13\nasync Promise.all (index 0)\nasync Promise.all (index 0)\nObject.publish (src/core/server/events/event.ts:61:7)\nObject.publishCommentCreated (src/core/server/services/events/comments.ts:71:5)\nasync Promise.all (index 1)\nObject.publishChanges (src/core/server/stacks/helpers/publishChanges.ts:76:3)\nObject.create (src/core/server/stacks/createComment.ts:469:3)\nObject.mapFieldsetToErrorCodes (src/core/server/graph/errors.ts:17:12)\ncreateComment (src/core/server/graph/resolvers/Mutation.ts:13:13)\n"
  },
  "tenantID":"xxxx",
  "payload":{
    "id":"xxxx",
    "createdAt":"2023-10-16T07:10:10.019Z",
    "data":{
      "commentID":"xxxx",
      "storyID":"xxxx",
      "siteID":"xxxxx"
    },
    "type":"COMMENT_CREATED"
  },
  "channel":{
    "enabled":true,
    "name":"Metro #coral",
    "hookURL":"https://hooks.slack.com/services/xxxx/xxxx/xxxx",
    "triggers":{
      "reportedComments":false,
      "pendingComments":false,
      "featuredComments":false,
      "allComments":true,
      "staffComments":false
    }
  },
  "msg":"could not post the comment to slack",
  "time":"2023-10-16T07:10:10.293Z",
  "src":{
    "file":"/usr/src/app/src/core/server/events/listeners/slack/slack.ts",
    "line":141
  },
  "v":0
}

Slack trace

SlackCoralEventListener.postMessage (src/core/server/events/listeners/slack/slack.ts:56:13)
runMicrotasks (<anonymous>)
src/core/server/events/listeners/slack/slack.ts:136:13
async Promise.all (index 0)
async Promise.all (index 0)
Object.publish (src/core/server/events/event.ts:61:7)
Object.publishCommentCreated (src/core/server/services/events/comments.ts:71:5)
async Promise.all (index 1)
Object.publishChanges (src/core/server/stacks/helpers/publishChanges.ts:76:3)
Object.create (src/core/server/stacks/createComment.ts:469:3)
Object.mapFieldsetToErrorCodes (src/core/server/graph/errors.ts:17:12)
createComment (src/core/server/graph/resolvers/Mutation.ts:13:13)

Expected behavior: All comments to be posted to Slack.

Actual behavior: Long comment not posted.

Version: Coral 8.5.0.

losowsky commented 11 months ago

Thanks for reporting - sounds like it's hitting a Slack limit. We'll add a ticket to our backlog to confirm

kabeaty commented 10 months ago

Hello, I looked into this and tested out posting a long comment to Slack from Coral. I was able to successfully send a comment with 1800 words/11000 characters to a Slack channel when using the text data variable in my workflow. Slack’s docs say that they support up to 40000 characters here (https://api.slack.com/methods/chat.postMessage#truncating).


However, for section blocks text fields, Slack says they support up to 3000 characters (https://api.slack.com/reference/block-kit/blocks#section). Perhaps this is the issue you are running into. We can update to truncate the text sent through there to less than 3000 characters so that it shouldn’t hit the limit in this case. I have opened this PR to address this: https://github.com/coralproject/talk/pull/4392

losowsky commented 9 months ago

Fixed in the latest release: https://github.com/coralproject/talk/releases/tag/v8.6.3 Thanks for reporting!