mattermost / mattermost-plugin-github

GitHub plugin for Mattermost
Apache License 2.0
157 stars 150 forks source link

Fix PR subscription error "You cannot update an existing Post" #754

Closed mickmister closed 4 months ago

mickmister commented 6 months ago

There's an issue in the pull request event webhook logic where we reuse the same post struct for multiple calls to CreatePost, resulting in this error:

CreatePost: You cannot update an existing Post.

https://community.mattermost.com/core/pl/wzjmxwip4tyapm67x6de9ff6zr

cpatulea commented 4 months ago

We're having the same issue. Two channels subscribed to the same Repository:

{
  "Repositories": {
    "foulab/": [
      {
        "ChannelID": "kh<snip>fa",
        "CreatorID": "j5<snip>wo",
        "Features": "pushes",
        "Flags": {
          "ExcludeOrgMembers": false,
          "RenderStyle": "",
          "ExcludeRepository": null
        },
        "Repository": "foulab/"
      },
      {
        "ChannelID": "wn<snip>5c",
        "CreatorID": "j5<snip>wo",
        "Features": "pushes",
        "Flags": {
          "ExcludeOrgMembers": false,
          "RenderStyle": "",
          "ExcludeRepository": null
        },
        "Repository": "foulab/"
      }
    ],

results in this error logs every time:

{"timestamp":"2024-05-28 19:35:33.262 -04:00","level":"warn","msg":"Error webhook post","caller":"app/plugin_api.go:979","plugin_id":"github","post":"&{Id:e1<snip>xh CreateAt:1716939333153 UpdateAt:1716939333153 EditAt:0 DeleteAt:0 IsPinned:false UserId:sz<snip>6w ChannelId:wn<snip>5c RootId: OriginalId: Message:\n[str4w](https://github.com/str4w) pushed [2 new commits](https://github.com/FOULAB/DrawingMachines/compare/192bfbab2164...179c374f834d) to [\\[FOULAB/DrawingMachines:plotter.writeup\\]](https://github.com/FOULAB/DrawingMachines/tree/plotter.writeup):\n[`24d863`](https://github.com/FOULAB/DrawingMachines/commit/24d863f4de73d4a861380d2796c507ab4a2a0f05) Switch the chipotle3 url back to upstream\n\nThe PR has been merged by upstream - 0x5c\n[`179c37`](https://github.com/FOULAB/DrawingMachines/commit/179c374f834defced2c8be08d9dec2285e7d36f4) Merge pull request #2 from 0x5c/fix/chipotle-url\n\nSwitch the chipotle3 url back to upstream - strawdog\n MessageSource: Type:custom_git_push propsMu:{w:{state:0 sema:0} writerSem:0 readerSem:0 readerCount:{_:{} v:0} readerWait:{_:{} v:0}} Props:map[from_bot:true from_plugin:true] Hashtags: Filenames:[] FileIds:[] PendingPostId: HasReactions:false RemoteId:<nil> ReplyCount:0 LastReplyAt:0 Participants:[] IsFollowing:<nil> Metadata:<nil>}","error":"CreatePost: You cannot update an existing Post."}

One of the subscribed channels (incidentally, that's a PM with me) gets the notification; the other channel does not.

I see there's a PR https://github.com/mattermost/mattermost-plugin-github/pull/755 open to fix this. Really looking forward to it being merged and included in a release!

cpatulea commented 3 months ago

Hello, I'm wondering if there will be a release soon (https://github.com/mattermost/mattermost-plugin-github/releases) that includes the fix for this issue?

cpatulea commented 3 months ago

Looks like v2.3.0 was just released yesterday: https://github.com/mattermost/mattermost-plugin-github/releases