Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistent behaviour on notifications #18

Open
BenCookie95 opened this issue Sep 17, 2024 · 4 comments
Open

Inconsistent behaviour on notifications #18

BenCookie95 opened this issue Sep 17, 2024 · 4 comments
Assignees

Comments

@BenCookie95
Copy link
Contributor

Notifications can be a little sporadic and incorrect, if you play around with a number of accounts you will notice incorrect names, duplicate notifications and missing notifications.

Heads up that these tests are flaky and you will have to play around a bit.

Prerequisites

You will need 3 different google accounts
Enable google drive notifications

Test 1

  1. Create a doc using the slash command, allow anyone to comment and publish to channel.
  2. Add some content to the document using the google account
  3. Using account 2 add a comment
  4. Using account 3 add another comment

Expected result: You get a notification for each comment
Actual result: I got a duplicate notification for the second comment but nothing for the first

Test 2

  1. Create a doc using the slash command, allow anyone to comment and publish to channel.
  2. Add some content to the document using the google account
  3. Using account 2 add a comment
  4. When you receive the Mattermost notification click the "Reply to comment" button and complete the form.
  5. Add another comment from account 2

Expected result: You get a notification for the last comment
Actual result: Instead of the notification being the last comment it will contain the content from your "reply to comment" form

Test 3

  1. Create a doc using the slash command, allow anyone to comment and publish to channel.
  2. Add some content to the document using the google account
  3. Open the document using incognito and comment using an anonymous account
  4. Comment using account 2

Expected Result: You receive 2 notifications
Actual result: I didn't get a notification for the anonymous comment. Sometimes the names on the notifications are incorrect.

I also randomly got this panic when doing test 3:

{"timestamp":"2024-09-17 15:52:28.506 -04:00","level":"warn","msg":"Recovered from a panic","caller":"app/plugin_api.go:1014","plugin_id":"com.mattermost-community.plugin-google-drive","url":"/api/v1/webhook?userID=6bmhe1mai3dqxn964xiphqwkdy","error":"runtime error: invalid memory address or nil pointer dereference","stack":"goroutine 4294 [running]:\nruntime/debug.Stack()\n\truntime/debug/stack.go:24 +0x64\ngithub.com/darkLord19/mattermost-plugin-google-drive/server/plugin.(*Plugin).withRecovery-fm.(*Plugin).withRecovery.func1.1()\n\tgithub.com/darkLord19/mattermost-plugin-google-drive/server/plugin/api.go:110 +0x5c\npanic({0x104e93ec0?, 0x105639770?})\n\truntime/panic.go:914 +0x218\ngithub.com/darkLord19/mattermost-plugin-google-drive/server/plugin.(*Plugin).handleCommentNotifications(0x1400015c300, {0x140003080f0, 0x2c}, {0x140001fcf57, 0x1a}, 0x1400057fc20, 0x140008749c0)\n\tgithub.com/darkLord19/mattermost-plugin-google-drive/server/plugin/notifications.go:175 +0x3b8\ngithub.com/darkLord19/mattermost-plugin-google-drive/server/plugin.(*Plugin).handleDriveWatchNotifications(0x1400015c300, 0x0?, {0x10500bf28, 0x140004b1d70}, 0x140009cc400)\n\tgithub.com/darkLord19/mattermost-plugin-google-drive/server/plugin/api.go:520 +0xa64\ngithub.com/darkLord19/mattermost-plugin-google-drive/server/plugin.(*Plugin).initializeAPI.(*Plugin).attachContext.func6({0x10500bf28, 0x140004b1d70}, 0x1400015c338?)\n\tgithub.com/darkLord19/mattermost-plugin-google-drive/server/plugin/api.go:99 +0x70\nnet/http.HandlerFunc.ServeHTTP(0x1400031b378?, {0x10500bf28?, 0x140004b1d70?}, 0x100?)\n\tnet/http/server.go:2136 +0x38\ngithub.com/darkLord19/mattermost-plugin-google-drive/server/plugin.(*Plugin).checkConfigured-fm.(*Plugin).checkConfigured.func1({0x10500bf28, 0x140004b1d70}, 0x140009cc400?)\n\tgithub.com/darkLord19/mattermost-plugin-google-drive/server/plugin/api.go:127 +0x8c\nnet/http.HandlerFunc.ServeHTTP(0xf8?, {0x10500bf28?, 0x140004b1d70?}, 0x104ac81d0?)\n\tnet/http/server.go:2136 +0x38\ngithub.com/darkLord19/mattermost-plugin-google-drive/server/plugin.(*Plugin).withRecovery-fm.(*Plugin).withRecovery.func1({0x10500bf28?, 0x140004b1d70?}, 0x14000680020?)\n\tgithub.com/darkLord19/mattermost-plugin-google-drive/server/plugin/api.go:114 +0x78\nnet/http.HandlerFunc.ServeHTTP(0x140009cc300?, {0x10500bf28?, 0x140004b1d70?}, 0x10442e7c4?)\n\tnet/http/server.go:2136 +0x38\ngithub.com/gorilla/..."}
{"timestamp":"2024-09-17 15:52:29.357 -04:00","level":"warn","msg":"Recovered from a panic","caller":"app/plugin_api.go:1014","plugin_id":"com.mattermost-community.plugin-google-drive","url":"/api/v1/webhook?userID=6bmhe1mai3dqxn964xiphqwkdy","error":"runtime error: invalid memory address or nil pointer dereference","stack":"goroutine 4389 [running]:\nruntime/debug.Stack()\n\truntime/debug/stack.go:24 +0x64\ngithub.com/darkLord19/mattermost-plugin-google-drive/server/plugin.(*Plugin).withRecovery-fm.(*Plugin).withRecovery.func1.1()\n\tgithub.com/darkLord19/mattermost-plugin-google-drive/server/plugin/api.go:110 +0x5c\npanic({0x104e93ec0?, 0x105639770?})\n\truntime/panic.go:914 +0x218\ngithub.com/darkLord19/mattermost-plugin-google-drive/server/plugin.(*Plugin).handleCommentNotifications(0x1400015c300, {0x140003bbb00, 0x2c}, {0x140008e2197, 0x1a}, 0x1400078ca00, 0x14000690660)\n\tgithub.com/darkLord19/mattermost-plugin-google-drive/server/plugin/notifications.go:175 +0x3b8\ngithub.com/darkLord19/mattermost-plugin-google-drive/server/plugin.(*Plugin).handleDriveWatchNotifications(0x1400015c300, 0x0?, {0x10500bf28, 0x140000dcfb0}, 0x140009cd200)\n\tgithub.com/darkLord19/mattermost-plugin-google-drive/server/plugin/api.go:520 +0xa64\ngithub.com/darkLord19/mattermost-plugin-google-drive/server/plugin.(*Plugin).initializeAPI.(*Plugin).attachContext.func6({0x10500bf28, 0x140000dcfb0}, 0x1400015c338?)\n\tgithub.com/darkLord19/mattermost-plugin-google-drive/server/plugin/api.go:99 +0x70\nnet/http.HandlerFunc.ServeHTTP(0x1400031b378?, {0x10500bf28?, 0x140000dcfb0?}, 0x100?)\n\tnet/http/server.go:2136 +0x38\ngithub.com/darkLord19/mattermost-plugin-google-drive/server/plugin.(*Plugin).checkConfigured-fm.(*Plugin).checkConfigured.func1({0x10500bf28, 0x140000dcfb0}, 0x140009cd200?)\n\tgithub.com/darkLord19/mattermost-plugin-google-drive/server/plugin/api.go:127 +0x8c\nnet/http.HandlerFunc.ServeHTTP(0xf8?, {0x10500bf28?, 0x140000dcfb0?}, 0x104ac81d0?)\n\tnet/http/server.go:2136 +0x38\ngithub.com/darkLord19/mattermost-plugin-google-drive/server/plugin.(*Plugin).withRecovery-fm.(*Plugin).withRecovery.func1({0x10500bf28?, 0x140000dcfb0?}, 0x14000680020?)\n\tgithub.com/darkLord19/mattermost-plugin-google-drive/server/plugin/api.go:114 +0x78\nnet/http.HandlerFunc.ServeHTTP(0x140009cd100?, {0x10500bf28?, 0x140000dcfb0?}, 0x10442e7c4?)\n\tnet/http/server.go:2136 +0x38\ngithub.com/gorilla/..."}
{"timestamp":"2024-09-17 15:52:30.097 -04:00","level":"warn","msg":"Recovered from a panic","caller":"app/plugin_api.go:1014","plugin_id":"com.mattermost-community.plugin-google-drive","url":"/api/v1/webhook?userID=6bmhe1mai3dqxn964xiphqwkdy","error":"runtime error: invalid memory address or nil pointer dereference","stack":"goroutine 4404 [running]:\nruntime/debug.Stack()\n\truntime/debug/stack.go:24 +0x64\ngithub.com/darkLord19/mattermost-plugin-google-drive/server/plugin.(*Plugin).withRecovery-fm.(*Plugin).withRecovery.func1.1()\n\tgithub.com/darkLord19/mattermost-plugin-google-drive/server/plugin/api.go:110 +0x5c\npanic({0x104e93ec0?, 0x105639770?})\n\truntime/panic.go:914 +0x218\ngithub.com/darkLord19/mattermost-plugin-google-drive/server/plugin.(*Plugin).handleCommentNotifications(0x1400015c300, {0x14000494e40, 0x2c}, {0x140008e3fd7, 0x1a}, 0x140003c20a0, 0x1400091af60)\n\tgithub.com/darkLord19/mattermost-plugin-google-drive/server/plugin/notifications.go:175 +0x3b8\ngithub.com/darkLord19/mattermost-plugin-google-drive/server/plugin.(*Plugin).handleDriveWatchNotifications(0x1400015c300, 0x0?, {0x10500bf28, 0x140007db370}, 0x140006a8500)\n\tgithub.com/darkLord19/mattermost-plugin-google-drive/server/plugin/api.go:520 +0xa64\ngithub.com/darkLord19/mattermost-plugin-google-drive/server/plugin.(*Plugin).initializeAPI.(*Plugin).attachContext.func6({0x10500bf28, 0x140007db370}, 0x1400015c338?)\n\tgithub.com/darkLord19/mattermost-plugin-google-drive/server/plugin/api.go:99 +0x70\nnet/http.HandlerFunc.ServeHTTP(0x140002ed378?, {0x10500bf28?, 0x140007db370?}, 0x100?)\n\tnet/http/server.go:2136 +0x38\ngithub.com/darkLord19/mattermost-plugin-google-drive/server/plugin.(*Plugin).checkConfigured-fm.(*Plugin).checkConfigured.func1({0x10500bf28, 0x140007db370}, 0x140006a8500?)\n\tgithub.com/darkLord19/mattermost-plugin-google-drive/server/plugin/api.go:127 +0x8c\nnet/http.HandlerFunc.ServeHTTP(0xf8?, {0x10500bf28?, 0x140007db370?}, 0x104ac81d0?)\n\tnet/http/server.go:2136 +0x38\ngithub.com/darkLord19/mattermost-plugin-google-drive/server/plugin.(*Plugin).withRecovery-fm.(*Plugin).withRecovery.func1({0x10500bf28?, 0x140007db370?}, 0x14000680020?)\n\tgithub.com/darkLord19/mattermost-plugin-google-drive/server/plugin/api.go:114 +0x78\nnet/http.HandlerFunc.ServeHTTP(0x140006a8400?, {0x10500bf28?, 0x140007db370?}, 0x10442e7c4?)\n\tnet/http/server.go:2136 +0x38\ngithub.com/gorilla/..."}
@BenCookie95
Copy link
Contributor Author

Spent some time debugging this and it looks like Google Drive activity api just sends the wrong comment a lot of the time. It's extremely flaky. @darkLord19 Did you notice this as well?

@darkLord19
Copy link
Contributor

darkLord19 commented Oct 7, 2024

@BenCookie95 I did notice duplicate notifications. Upon checking in google api doc they have mentioned that if webhook server doesn't respond with ok status code then google will try to redeliver the same event with exponential backoff. As far as I am aware we do respond with status ok for webhook requests. Maybe our response takes longer than google is expecting or maybe something else. I will have a look at this and see what i find out.

I haven't encountered any panics though. I will try to replicate it using steps you mentioned and see if I encounter it.

@BenCookie95
Copy link
Contributor Author

@darkLord19 I'm already looking into this issue, I nearly have it resolved

@darkLord19
Copy link
Contributor

@BenCookie95 ohh alright. I was away for few days so just saw all the notifications. Let me know if there are any other issues which needs debugging.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants