Flaky Inclusion of Share Expiration Notification in Grouped Emails
Describe the bug
There is an inconsistent behavior while delivering grouped email notifications concerning share expiration. Specifically, when multiple events occur, the daily summary email occasionally fails to include notifications for expired share, which might lead to unreliable communication.
Steps to reproduce
Note: Both in-app and email notifications are enabled for events: Share Received, Share Removed, Share Expired, Added as space member, Removed as space member. Space membership expired
- Brian enables "daily" as "Email sending interval" from
My Account->Preferences->Notifications - Alice creates a file "lorem.txt" with any text content
- Alice shares "lorem.txt" to Brian with viewer role and
- Alice expires the share "lorem.txt" shared with Brian
- Trigger the CLI command for grouped email notification:
notifications send-email --daily
Refs for more description of email cycles: https://github.com/owncloud/ocis/issues/10793 Refs for the steps: https://github.com/owncloud/ocis/pull/11010
Expected behavior
Message related to the expiration of file "lorem.txt" should have been included after the message related to Alice sharing "lorem.txt" with
Your share to lorem.txt has expired at <expired-date>
Even though this share has been revoked you still might have access through other shares and/or space memberships.
Actual behavior
Message related to the expiration of file "lorem.txt" comes with the message in inbox somewhat like:
Your membership of space Alice Hansen has expired at 2025-02-13 00:00:00
Even though this membership has expired you still might have access through other shares and/or space memberships
For the above mentioned steps, the test ↓ sometime gets passed including the expiration message:
Scenario: get daily grouped email notification # /drone/src/tests/acceptance/features/cliCommands/emailNotification.feature:16
Given user "Brian" has set the email sending interval to "daily" using the settings API # SettingsContext::userHasSetTheEmailSendingIntervalToUsingTheSettingsAPI()
And user "Alice" has sent the following resource share invitation: # SharingNgContext::userHasSentTheFollowingResourceShareInvitation()
| resource | lorem.txt |
| space | Personal |
| sharee | Brian |
| shareType | user |
| permissionsRole | Viewer |
| expirationDateTime | 2042-01-01T23:59:59.000Z |
And user "Alice" has expired the last share of resource "lorem.txt" inside of the space "Personal" # SpacesContext::userHasExpiredTheLastShareOfResourceInsideOfTheSpace()
When the administrator triggers "daily" email notifications using the CLI # CliContext::theAdministratorTriggersEmailNotificationsUsingTheCLI()
Then the command should be successful # CliContext::theCommandShouldBeSuccessful()
And the command output should contain "successfully sent SendEmailsEvent" # CliContext::theCommandOutputShouldContain()
And user "Brian" should have received the following email from user "Alice" # NotificationContext::userShouldHaveReceivedTheFollowingEmailFromUser()
"""
Hi Brian Murphy,
Alice Hansen has shared "lorem.txt" with you.
Your membership of space Alice Hansen has expired at 2025-02-16 00:00:00
Even though this membership has expired you still might have access through other shares and/or space memberships
"""
│ [INFO] Mailbox is empty...
│
Passing build: https://drone.owncloud.com/owncloud/ocis/43512/16/9
But sometime for the same above mentioned steps, it doesn't include message related to expiration of the file "lorem.txt", making the test fail:
Scenario: get daily grouped email notification # /drone/src/tests/acceptance/features/cliCommands/emailNotification.feature:16
Given user "Brian" has set the email sending interval to "daily" using the settings API # SettingsContext::userHasSetTheEmailSendingIntervalToUsingTheSettingsAPI()
And user "Alice" has sent the following resource share invitation: # SharingNgContext::userHasSentTheFollowingResourceShareInvitation()
| resource | lorem.txt |
| space | Personal |
| sharee | Brian |
| shareType | user |
| permissionsRole | Viewer |
| expirationDateTime | 2042-01-01T23:59:59.000Z |
And user "Alice" has expired the last share of resource "lorem.txt" inside of the space "Personal" # SpacesContext::userHasExpiredTheLastShareOfResourceInsideOfTheSpace()
When the administrator triggers "daily" email notifications using the CLI # CliContext::theAdministratorTriggersEmailNotificationsUsingTheCLI()
Then the command should be successful # CliContext::theCommandShouldBeSuccessful()
And the command output should contain "successfully sent SendEmailsEvent" # CliContext::theCommandOutputShouldContain()
And user "Brian" should have received the following email from user "Alice" # NotificationContext::userShouldHaveReceivedTheFollowingEmailFromUser()
"""
Hi Brian Murphy,
Alice Hansen has shared "lorem.txt" with you.
Your membership of space Alice Hansen has expired at 2025-02-16 00:00:00
Even though this membership has expired you still might have access through other shares and/or space memberships
"""
The email address '[email protected]' should have received an email with the body containing Hi Brian Murphy,
Alice Hansen has shared "lorem.txt" with you.
Your membership of space Alice Hansen has expired at 2025-02-16 00:00:00
Even though this membership has expired you still might have access through other shares and/or space memberships
but the received email is Hi Brian Murphy,
Alice Hansen has shared "lorem.txt" with you.
---
ownCloud - Store. Share. Work.
https://owncloud.com
Failing build: https://drone.owncloud.com/owncloud/ocis/43468/16/9, https://drone.owncloud.com/owncloud/ocis/43500/16/9, https://drone.owncloud.com/owncloud/ocis/44239/19/9
Request log:
### And user "Brian" should have received the following email from user "Alice"
_______________________________________________________________________
==> REQUEST
GET /api/v1/mailbox/brian
X-Request-ID: cliCommands/emailNotification.feature:16-29
<== RESPONSE
200 OK
Content-Length: 300
<== RES BODY
[{"mailbox":"brian","id":"20250217T072951-0001","from":"\"ownCloud\" \[email protected]\u003e via ownCloud \[email protected]\u003e","to":["\[email protected]\u003e"],"subject":"Report","date":"2025-02-17T07:29:51.11419202Z","posix-millis":1739777391114,"size":2313,"seen":false}]
_______________________________________________________________________
==> REQUEST
GET /api/v1/mailbox/brian/20250217T072951-0001
X-Request-ID: cliCommands/emailNotification.feature:16-29
<== RESPONSE
200 OK
Transfer-Encoding: chunked
<== RES BODY
{"mailbox":"brian","id":"20250217T072951-0001","from":"\"ownCloud\" \[email protected]\u003e via ownCloud \[email protected]\u003e","to":["\[email protected]\u003e"],"subject":"Report","date":"2025-02-17T07:29:51.11419202Z","posix-millis":1739777391114,"size":2313,"seen":false,"body":{"text":"Hi Brian Murphy,\n\nAlice Hansen has shared \"lorem.txt\" with you.\n\n\n---\nownCloud - Store. Share. Work.\nhttps://owncloud.com\n","html":"\u003c!DOCTYPE html\u003e\n\u003chtml\u003e\n\u003cbody\u003e\n\u003ctable cellspacing=\"0\" cellpadding=\"0\" border=\"0\" width=\"100%\"\u003e\n \u003ctr\u003e\n \u003ctd\u003e\n \u003ctable cellspacing=\"0\" cellpadding=\"0\" border=\"0\" width=\"600px\"\u003e\n \u003ctr\u003e\n \u003ctd width=\"20px\"\u003e\u0026nbsp;\u003c/td\u003e\n \u003ctd style=\"font-weight:normal; font-size:0.8em; line-height:1.2em; font-family:verdana,'arial',sans;\"\u003e\n Hi Brian Murphy,\n \u003cbr\u003e\u003cbr\u003e\n Alice Hansen has shared \"lorem.txt\" with you.\n \u003c/td\u003e\n \u003c/tr\u003e\n \u003ctr\u003e\n \u003ctd colspan=\"2\"\u003e\u0026nbsp;\u003c/td\u003e\n \u003c/tr\u003e\n \u003ctr\u003e\n \u003ctd width=\"20px\"\u003e\u0026nbsp;\u003c/td\u003e\n \u003ctd style=\"font-weight:normal; font-size:0.8em; line-height:1.2em; font-family:verdana,'arial',sans;\"\u003e\n \u003cfooter\u003e\n \u003cbr\u003e\n \u003cbr\u003e\n --- \u003cbr\u003e\n ownCloud - Store. Share. Work.\u003cbr\u003e\n \u003ca href=\"https://owncloud.com\"\u003ehttps://owncloud.com\u003c/a\u003e\n \u003c/footer\u003e\n \u003c/td\u003e\n \u003c/tr\u003e\n \u003ctr\u003e\n \u003ctd colspan=\"2\"\u003e\u0026nbsp;\u003c/td\u003e\n \u003c/tr\u003e\n \u003c/table\u003e\n \u003c/td\u003e\n \u003c/tr\u003e\n\u003c/table\u003e\n\u003c/body\u003e\n\u003c/html\u003e\n"},"header":{"Content-Type":["multipart/alternative; boundary=a3206f5f64a1293f8620daff1c5a160c54e00a02605ddaac7e9b529f0b8b"],"Date":["Mon, 17 Feb 2025 07:29:51 +0000"],"From":["\"\\\"ownCloud\\\" \[email protected]\u003e via ownCloud\" \[email protected]\u003e"],"Mime-Version":["1.0"],"Received":["from localhost ([172.25.7.2]) by inbucket for \[email protected]\u003e; Mon, 17 Feb 2025 07:29:51 +0000 (UTC)"],"Subject":["Report"],"To":["\[email protected]\u003e"]},"attachments":[]}
Trying locally also produces above flakiness: The expiration message coming:
https://github.com/user-attachments/assets/7544f817-9bf5-47bd-927d-5b4f81c692f6
The expiration message is not coming:
https://github.com/user-attachments/assets/dcd0e3c6-4c81-43d5-bdcd-503659fc5917
Closing this issue after finding out it is not flaky and share expiration notifications are only sent after user calls the resource (not at expiration time) mentioned in https://github.com/owncloud/ocis/issues/11690 and https://github.com/owncloud/ocis/issues/10966#issuecomment-2739550203