atlassian-labs / atlassian-slack-integration-server

Slack plugins for Jira, Confluence and Bitbucket Server
Apache License 2.0
32 stars 25 forks source link

Unsupported layout block type: rich_text with double notifications in Slack #228

Closed Pigueiras closed 2 years ago

Pigueiras commented 2 years ago

Hello,

I'm using the "Jira Server for Slack (Official)" plugin for Slack and since yesterday we're getting duplicate notifications in our Slack channel. If I look at the logs I can see that it retries two times to add the slack message into the channel but it can't parse the JSON response from the Slack server.

2022-10-14 11:11:40,147+0200 jira-slack-plugin:thread-1 WARN XXX XXXX XXXX ... /secure/QuickCreateIssue.jspa [c.a.p.slack.util.ResponseMapper] Error when performing request to Slack: chat.postMessage/XXXX
com.google.gson.JsonParseException: Unsupported layout block type: rich_text
        at com.github.seratch.jslack.common.json.GsonLayoutBlockFactory.getLayoutClassInstance(GsonLayoutBlockFactory.java:36)
        at com.github.seratch.jslack.common.json.GsonLayoutBlockFactory.deserialize(GsonLayoutBlockFactory.java:19)
        at com.github.seratch.jslack.common.json.GsonLayoutBlockFactory.deserialize(GsonLayoutBlockFactory.java:12)
        at com.google.gson.internal.bind.TreeTypeAdapter.read(TreeTypeAdapter.java:69)
        at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.read(TypeAdapterRuntimeTypeWrapper.java:41)
        at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:82)
        at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:61)
        at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:131)
        at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:222)
        at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:131)
        at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:222)
        at com.google.gson.Gson.fromJson(Gson.java:963)
        at com.google.gson.Gson.fromJson(Gson.java:928)
        at com.google.gson.Gson.fromJson(Gson.java:877)
        at com.google.gson.Gson.fromJson(Gson.java:848)
        at com.github.seratch.jslack.common.http.SlackHttpClient.parseJsonResponse(SlackHttpClient.java:81)
        at com.github.seratch.jslack.api.methods.impl.MethodsClientImpl.doPostFormWithToken(MethodsClientImpl.java:913)
        at com.github.seratch.jslack.api.methods.impl.MethodsClientImpl.chatPostMessage(MethodsClientImpl.java:304)
        at com.atlassian.plugins.slack.api.client.DefaultSlackClient.lambda$postMessage$23(DefaultSlackClient.java:494)
        at com.atlassian.plugins.slack.util.ResponseMapper.toEither(ResponseMapper.java:25)
        at com.atlassian.plugins.slack.api.client.DefaultSlackClient.postMessage(DefaultSlackClient.java:492)
        at com.atlassian.jira.plugins.slack.service.task.impl.SendNotificationTask.lambda$null$0(SendNotificationTask.java:89)
        at java.util.Optional.flatMap(Optional.java:241)
        at com.atlassian.plugins.slack.api.client.RetryLoaderHelper.lambda$retryWithUserTokens$1(RetryLoaderHelper.java:25)
        at java.util.stream.ReferencePipeline$7$1.accept(ReferencePipeline.java:269)
        at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
        at java.util.Spliterators$ArraySpliterator.tryAdvance(Spliterators.java:958)
        at java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:126)
        at java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:499)
        at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:486)
        at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:472)
        at java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:152)
        at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
        at java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:531)
        at com.atlassian.plugins.slack.api.client.RetryLoaderHelper.retryWithUserTokens(RetryLoaderHelper.java:26)
        at com.atlassian.jira.plugins.slack.service.task.impl.SendNotificationTask.lambda$call$1(SendNotificationTask.java:87)
        at com.atlassian.jira.plugins.slack.service.task.impl.DefaultTaskExecutorService.lambda$submitTask$1(DefaultTaskExecutorService.java:94)
        at com.google.common.util.concurrent.TrustedListenableFutureTask$TrustedFutureInterruptibleTask.runInterruptibly(TrustedListenableFutureTask.java:125)
        at com.google.common.util.concurrent.InterruptibleTask.run(InterruptibleTask.java:57)
        at com.google.common.util.concurrent.TrustedListenableFutureTask.run(TrustedListenableFutureTask.java:78)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:750)

I also include in this issue the exact response from the Slack, in case it helps (let me know if you want me to add any other information).

2022-10-14 10:17:04,818+0200 jira-slack-plugin:thread-3 DEBUG user XXXX XXXX 1.2.3.4,4.3.2.1 /secure/AssignIssue.jspa [c.g.s.j.c.http.listener.DetailedLoggingListener]
    [Request URL]
    POST https://slack.com/api/chat.postMessage
    [Specified Request Headers]
    Authorization: Bearer XXXXXXXXXXXXXXXXXXXXXXXXXXXX
    X-Atlassian-Request-Id: XXXXXXXXXXXXXXXXXXXXXXXXXXX
    [Request Body]
    channel=XYZ&text=%3Chttps%3A%2F%2Fexample.example.org%2Fproject%2Fdevissues%2Fsecure%2FViewProfile.jspa%3Fname%3Duser%26atlLinkOrigin%3Dxxxxxxx50ZWdyYXRpb258dXNlcg%253D%253D%7Cxxxxx%20users%3E%20has%20*assigned*%20a%20Support%20request%20to%20%3Chttps%3A
%2F%2Fexample.example.org%2Fproject%2Fdevissues%2Fsecure%2FViewProfile.jspa%3Fname%3Duser%26atlLinkOrigin%3Dxxxxxxx50ZWdyYXRpb258dXNlcg%253D%253D%7Cxxxxx%20users%3E&link_names=0&mrkdwn=1&attachments=%5B%7B%22fallback%22%3A%22HELP-14937%20blah%20my%20test%20ticket%
22%2C%22color%22%3A%22%232684FF%22%2C%22is_msg_unfurl%22%3Afalse%2C%22is_reply_unfurl%22%3Afalse%2C%22is_thread_root_unfurl%22%3Afalse%2C%22is_app_unfurl%22%3Afalse%2C%22title%22%3A%22HELP-14937%3A%20blah%20my%20test%20ticket%22%2C%22title_link%22%3A%22https%3A%2F%2Fbbp
team.example.org%2Fproject%2Fdevissues%2Fbrowse%2FHELP-14937%3FatlLinkOrigin%5Cuaaaaa2staW50ZWdyYXRpb258aXNzdWU%253D%22%2C%22text%22%3A%22Status%3A%20%60Open%60%20%20%20%20%20%20%20Assignee%3A%20*%5Cu003chttps%3A%2F%2Fexample.epfl.ch%2Fproject%2Fdevissues%2Fsecure%2FVie
wProfile.jspa%3Fname%5Cu003duser%5Cu0026atlLinkOrigin%5Cuaaaaa2staW50ZWdyYXRpb258dXNlcg%253D%253D%7Cxxxxx%20users%5Cu003e*%20%20%20%20%20%20%20Priority%3A%20*Minor*%22%2C%22footer%22%3A%22%5Cu003chttps%3A%2F%2Fexample.example.org%2Fproject%2Fdevissues%2Fprojects%
2FHELP%3FatlLinkOrigin%5Cuaaaaa2staW50ZWdyYXRpb258cHJvamVjdA%253D%253D%7CHelpdesk%20support%5Cu003e%20%7C%20%5Cu003chttps%3A%2F%2Fexample.example.org%2Fproject%2Fdevissues%3FatlLinkOrigin%5Cuaaaaa2staW50ZWdyYXRpb258c2l0ZQ%253D%253D%7CBlue%20Brain%20Project%20Jira%20
Issue%20Tracker%5Cu003e%22%2C%22footer_icon%22%3A%22https%3A%2F%2Fexample.example.org%2Fproject%2Fdevissues%2Fsecure%2Fprojectavatar%3Fsize%5Cu003dxsmall%5Cu0026pid%5Cu003d10662%5Cu0026avatarId%5Cu003d10460%5Cu0026format%5Cu003dpng%22%2C%22mrkdwn_in%22%3A%5B%22text%22%2C%22
pretext%22%5D%7D%5D&unfurl_links=0&unfurl_media=0&reply_broadcast=0

    Content-Type: application/x-www-form-urlencoded
    Content Length: 1953

    [Response Status]
    200
    [Response Headers]
    date: Fri, 14 Oct 2022 08:17:04 GMT
    server: Apache
    x-powered-by: HHVM/4.153.1
    access-control-allow-origin: *
    referrer-policy: no-referrer
    x-slack-backend: r
    x-slack-unique-id: YXXXXXXXXXXXXX
    strict-transport-security: max-age=31536000; includeSubDomains; preload
    access-control-allow-headers: slack-route, x-slack-version-ts, x-b3-traceid, x-b3-spanid, x-b3-parentspanid, x-b3-sampled, x-b3-flags
    access-control-expose-headers: x-slack-req-id, retry-after
    x-oauth-scopes: identify,bot:basic
    x-accepted-oauth-scopes: chat:write:bot,post
    expires: Mon, 26 Jul 1997 05:00:00 GMT
    cache-control: private, no-cache, no-store, must-revalidate
    pragma: no-cache
    x-xss-protection: 0
    x-content-type-options: nosniff
    x-slack-req-id: xxxxxx
    vary: Accept-Encoding
    content-type: application/json; charset=utf-8
    x-envoy-upstream-service-time: 496
    x-backend: main_normal main_bedrock_normal_with_overflow main_canary_with_overflow main_bedrock_canary_with_overflow main_control_with_overflow main_bedrock_control_with_overflow
    x-server: slack-www-hhvm-main-iad-lckq
    x-slack-shared-secret-outcome: no-match
    via: envoy-www-iad-tby3, envoy-edge-fra-fqpm
    x-edge-backend: envoy-www
    x-slack-edge-shared-secret-outcome: no-match
    [Response Body]
    {"ok":true,"channel":"XYZ","ts":"1665735424.735979","message":{"type":"message","subtype":"bot_message","text":"<https:\/\/example.example.org\/project\/devissues\/secure\/ViewProfile.jspa?name=user&amp;atlLinkOrigin=xxxxxxx50ZWdyYXRpb258dXNlcg%3D%3D|xxxxx xxxxx> has *assigned* a Support request to <https:\/\/example.epfl.ch\/project\/devissues\/secure\/ViewProfile.jspa?name=user&amp;atlLinkOrigin=xxxxxxx50ZWdyYXRpb258dXNlcg%3D%3D|xxxxx users>","ts":"1665735424.735979","username":"Jira","bot_id":"B0108JFAYCU"
,"app_id":"A01092Z73T7","attachments":[{"id":1,"color":"2684FF","fallback":"HELP-14937 blah my test ticket","text":"Status: `
Open`       Assignee: *<https:\/\/example.example.org\/project\/devissues\/secure\/ViewProfile.jspa?name=user&amp;atlLinkOrigin=xxxxxxx50ZWdyYXRpb258dXNlcg%3D%3D|xxxxx users>*       Priority: *Minor*","title":"HELP-14937: blah my test ticket","title_link":"https:\/\/example.epfl.ch\/project\/devissues\/browse\/HELP-14937?atlLinkOrigin=xxxxxxx50ZWdyYXRpb258aXNzdWU%3D","footer":"<https:\/\/example.epfl.ch\/project\/devissues\/projects\/HELP?atlLinkOrigin=xxxxxxx50ZWdyYXRpb258cHJvamVjdA%3D%3D|Helpdesk support> | <https:\/\/example.epfl.ch\/project\/devissues?atlLinkOrigin=xxxxxxx50ZWdyYXRpb258c2l0ZQ%3D%3D|Blue Brain Project Jira Issue Tracker>","mrkdwn_in":["pretext","text"]}],"blocks":[{"type":"rich_text","block_id":"jqp","elements":[{"type":"rich_text_section","elements":[{"type":"link","url":"https:\/\/example.epfl.ch\/project\/devissues\/secure\/ViewProfile.jspa?name=user&amp;atlLinkOrigin=xxxxxxx50ZWdyYXRpb258dXNlcg%3D%3D","text":"xxxxx users"},{"type":"text","text":" has "},{"type":"text","text":"assigned","style":{"bold":true}},{"type":"text","text":" a Support request to "},{"type":"link","url":"https:\/\/example.epfl.ch\/project\/devissues\/secure\/ViewProfile.jspa?name=user&amp;atlLinkOrigin=xxxxxxx50ZWdyYXRpb258dXNlcg%3D%3D","text":"xxxxx users"}]}]}]}}

Could it be that the jslack dependency needs to be updated from 1.5.6? If I look at the latest version from jslack I can see that there are some rich_text in the code in order to parse these JSON blocks. In any case it wouldn't explain why we've suddently started to experience this duplicates :(.

superoni commented 2 years ago

I confirm the same problem.

mvlasovatl commented 2 years ago

Hey @Pigueiras @superoni ! The hotfix build for this issue should be already available on the Marketplace - Jira Server for Slack 3.0.2. Logs about unsupported block will still show up for now, but there should be no notification duplicates anymore. Adding a proper support for rich_text block and getting rid of the error message takes some time will be implemented in a while.

Pigueiras commented 2 years ago

@mvlasovatl Thanks a lot! I confirm that we don't see the duplicates anymore. Thanks for the prompt reaction 👍