Deck: Mail notification is broken

Created on 17 Sep 2019  路  15Comments  路  Source: nextcloud/deck

Steps to reproduce

  1. Change description or user assignment or anything that creates a mail notification
  2. Wait for sending the mail notification
  3. See error in the log

Expected behaviour

There should be no error and the mail notification should be sent.

Actual behaviour

No mail notification is sent.

Server configuration detail

Operating system: Linux 4.19.0-0.bpo.5-amd64 #1 SMP Debian 4.19.37-5+deb10u2~bpo9+1 (2019-08-16) x86_64

Webserver: nginx/1.10.3 (fpm-fcgi)

Database: mysql 10.1.38

PHP version:

7.3.9-1+0~20190902.44+debian9~1.gbpf8534c
Modules loaded: Core, date, libxml, openssl, pcre, zlib, filter, hash, Reflection, SPL, sodium, session, standard, cgi-fcgi, mysqlnd, PDO, xml, apcu, bcmath, calendar, ctype, curl, dom, mbstring, fileinfo, ftp, gd, gettext, iconv, imagick, intl, json, exif, mysqli, pdo_mysql, pdo_pgsql, pdo_sqlite, pgsql, Phar, posix, readline, shmop, SimpleXML, smbclient, sockets, sqlite3, sysvmsg, sysvsem, sysvshm, tokenizer, wddx, xmlreader, xmlwriter, xsl, zip, libsmbclient, Zend OPcache

Nextcloud version: 16.0.4 - 16.0.4.1

Updated from an older Nextcloud/ownCloud or fresh install: Update from Owncloud 9 to Nextcloud 10 and then all available updates

Where did you install Nextcloud from: Crossupdate from website

Signing status

Array
(
)

List of activated apps

Enabled:
 - accessibility: 1.2.0
 - activity: 2.9.1
 - admin_audit: 1.6.0
 - apporder: 0.7.1
 - calendar: 1.7.1
 - cloud_federation_api: 0.2.0
 - comments: 1.6.0
 - contacts: 3.1.3
 - dav: 1.9.2
 - deck: 0.6.6
 - drawio: 0.9.3
 - federatedfilesharing: 1.6.0
 - federation: 1.6.0
 - files: 1.11.0
 - files_external: 1.7.0
 - files_pdfviewer: 1.5.0
 - files_rightclick: 0.15.1
 - files_sharing: 1.8.0
 - files_texteditor: 2.8.0
 - files_trashbin: 1.6.0
 - files_versions: 1.9.0
 - files_videoplayer: 1.5.0
 - gallery: 18.3.0
 - groupfolders: 4.1.0
 - issuetemplate: 0.5.0
 - keeweb: 0.5.1
 - logreader: 2.1.0
 - lookup_server_connector: 1.4.0
 - notifications: 2.4.1
 - oauth2: 1.4.2
 - onlyoffice: 3.0.0
 - password_policy: 1.6.0
 - polls: 0.10.2
 - privacy: 1.0.0
 - provisioning_api: 1.6.0
 - rainloop: 6.0.3
 - richdocuments: 3.4.1
 - serverinfo: 1.6.0
 - sharebymail: 1.6.0
 - spreed: 6.0.4
 - support: 1.0.0
 - systemtags: 1.6.0
 - tasks: 0.11.2
 - theming: 1.7.0
 - twofactor_backupcodes: 1.5.0
 - updatenotification: 1.6.0
 - viewer: 1.1.0
 - workflowengine: 1.6.0
Disabled:
 - encryption
 - firstrunwizard
 - mail
 - nextcloud_announcements
 - recommendations
 - survey_client
 - user_ldap

Configuration (config/config.php)

{
    "instanceid": "***REMOVED SENSITIVE VALUE***",
    "passwordsalt": "***REMOVED SENSITIVE VALUE***",
    "secret": "***REMOVED SENSITIVE VALUE***",
    "trusted_domains": [
        "***REMOVED SENSITIVE VALUE***"
    ],
    "datadirectory": "***REMOVED SENSITIVE VALUE***",
    "overwrite.cli.url": "https:\/\/***REMOVED SENSITIVE VALUE***",
    "dbtype": "mysql",
    "version": "16.0.4.1",
    "installed": true,
    "memcache.local": "\\OC\\Memcache\\APCu",
    "user_webdavauth_url": "",
    "theme": "",
    "log_type": "file",
    "loglevel": 2,
    "logtimezone": "Europe\/Berlin",
    "maintenance": false,
    "trashbin_retention_obligation": "auto",
    "dbname": "***REMOVED SENSITIVE VALUE***",
    "dbhost": "***REMOVED SENSITIVE VALUE***",
    "dbuser": "***REMOVED SENSITIVE VALUE***",
    "dbpassword": "***REMOVED SENSITIVE VALUE***",
    "mail_smtpmode": "smtp",
    "mail_smtpsecure": "ssl",
    "mail_smtpauthtype": "LOGIN",
    "mail_from_address": "***REMOVED SENSITIVE VALUE***",
    "mail_domain": "***REMOVED SENSITIVE VALUE***",
    "mail_smtpauth": 1,
    "mail_smtphost": "***REMOVED SENSITIVE VALUE***",
    "mail_smtpport": "465",
    "mail_smtpname": "***REMOVED SENSITIVE VALUE***",
    "mail_smtppassword": "***REMOVED SENSITIVE VALUE***",
    "mysql.utf8mb4": true,
    "mail_sendmailmode": "smtp"
}

Are you using external storage, if yes which one: smb

Are you using encryption:

Are you using an external user-backend, if yes which one: No

Client configuration

Browser: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36

Operating system: MacOS X 10.14.6

Logs

Web server error log

No webserver error.

Nextcloud log

[cron] Error: TypeError: Argument 3 passed to OCA\Deck\Activity\DeckProvider::setSubjects() must be of the type array, null given, called in /xxx/apps/deck/lib/Activity/DeckProvider.php on line 151 at <<closure>>

0. /xxx/apps/deck/lib/Activity/DeckProvider.php line 151
   OCA\Deck\Activity\DeckProvider->setSubjects(OC\Activity\Event {}, "{user} has adde ... }", null)
1. /xxx/apps/activity/lib/MailQueueHandler.php line 447
   OCA\Deck\Activity\DeckProvider->parse("en", OC\Activity\Event {})
2. /xxx/apps/activity/lib/MailQueueHandler.php line 352
   OCA\Activity\MailQueueHandler->parseEvent("en", OC\Activity\Event {})
3. /xxx/apps/activity/lib/MailQueueHandler.php line 163
   OCA\Activity\MailQueueHandler->sendEmailToUser("xxx", "[email protected]", "en", "Europe/Berlin", 1568662205)
4. /xxx/apps/activity/lib/BackgroundJob/EmailNotification.php line 65
   OCA\Activity\MailQueueHandler->sendEmails(500, 1568662205)
5. /xxx/lib/private/BackgroundJob/Job.php line 61
   OCA\Activity\BackgroundJob\EmailNotification->run(null)
6. /xxx/lib/private/BackgroundJob/TimedJob.php line 55
   OC\BackgroundJob\Job->execute(OC\BackgroundJob\JobList {}, OC\Log {})
7. /xxx/cron.php line 123
   OC\BackgroundJob\TimedJob->execute(OC\BackgroundJob\JobList {}, OC\Log {})

at 2019-09-16T21:30:07+02:00

Browser log

No browser error.


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

2. developing bug activity

Most helpful comment

Found the bug !
it happen when description is quite large. The DB field is limited to 4000 chars...

therefore we just need to truncate description below 4000, minus { " " and }

I'll try to make a PR, but this is simple to correct !

All 15 comments

Some more information: I have had this situation several times in the last two weeks.

At the moment the mail notification is working again after I deleted all entries of activity_mq. But that fix does not work everytime.

I can confirme the bug (NC 15 & Deck 0.6.6)

If I force activity:send-mails I get :

An unhandled exception has been thrown:
TypeError: Argument 3 passed to OCA\Deck\Activity\DeckProvider::setSubjects() must be of the type array, null given, called in /var/www/nextcloud/apps/deck/lib/Activity/DeckProvider.php on line 151 and defined in /var/www/nextcloud/apps/deck/lib/Activity/DeckProvider.php:162
Stack trace:

0 /var/www/nextcloud/apps/deck/lib/Activity/DeckProvider.php(151): OCA\Deck\Activity\DeckProvider->setSubjects(Object(OC\Activity\Event), '{user} a ajout\xC3...', NULL)

1 /var/www/nextcloud/apps/activity/lib/MailQueueHandler.php(469): OCA\Deck\Activity\DeckProvider->parse('fr', Object(OC\Activity\Event))

2 /var/www/nextcloud/apps/activity/lib/MailQueueHandler.php(374): OCA\Activity\MailQueueHandler->parseEvent('fr', Object(OC\Activity\Event))

3 /var/www/nextcloud/apps/activity/lib/MailQueueHandler.php(183): OCA\Activity\MailQueueHandler->sendEmailToUser('abelard-a', 'arnaud.abelard@...', 'fr', 'Europe/Berlin', 1570713059)

4 /var/www/nextcloud/apps/activity/lib/Command/SendEmails.php(111): OCA\Activity\MailQueueHandler->sendEmails(500, 1570713059, true, NULL)

5 /var/www/nextcloud/3rdparty/symfony/console/Command/Command.php(255): OCA\Activity\Command\SendEmails->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

6 /var/www/nextcloud/core/Command/Base.php(166): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

7 /var/www/nextcloud/3rdparty/symfony/console/Application.php(946): OC\Core\Command\Base->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

8 /var/www/nextcloud/3rdparty/symfony/console/Application.php(248): Symfony\Component\Console\Application->doRunCommand(Object(OCA\Activity\Command\SendEmails), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

9 /var/www/nextcloud/3rdparty/symfony/console/Application.php(148): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

10 /var/www/nextcloud/lib/private/Console/Application.php(213): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

11 /var/www/nextcloud/console.php(96): OC\Console\Application->run()

12 /var/www/nextcloud/occ(11): require_once('/var/www/nextcl...')

Deleting entries for activity_mq solve the issue !

Related to https://github.com/nextcloud/deck/issues/921 ?

The last weeks the notification for deck issues didn't work at all. Even if I deleted all entries in activity_mq, the following errors appears in this order.

[PHP] Error: Undefined offset: 2 at /xxx/apps/deck/lib/Notification/Notifier.php#117
GET /ocs/v2.php/apps/notifications/api/v2/notifications

[PHP] Error: Undefined offset: 2 at /xxx/apps/deck/lib/Notification/Notifier.php#107
GET /ocs/v2.php/apps/notifications/api/v2/notifications

[PHP] Error: Undefined offset: 2 at /xxx/apps/deck/lib/Notification/Notifier.php#103
GET /ocs/v2.php/apps/notifications/api/v2/notifications

Found the bug !
it happen when description is quite large. The DB field is limited to 4000 chars...

therefore we just need to truncate description below 4000, minus { " " and }

I'll try to make a PR, but this is simple to correct !

I have digged a little more into the code.

It seems that the issue is more into the activity app.

When the event is created (CARD_UPDATE_DESCRIPTION), the subjectparams field from the oc_activity table is filled. There is no issue there as this field is a longtext type. So even if description is very long, it fit into the field.

However, when mails need to be sent, the oc_activity_mq table is feeded and here, the amq_subjectparams field is a VARCHAR(4000) !
Therefore, the copy between the two table fail !

From what I understand this copy is done by the app activity or by the nextcloud core.
@juliushaertl , can you confirm that ?

A simple solution is tho change field type from VARCHAR(4000) to LONGTEXT in the oc_activity_mq table.

This is definitely a activity issue !
See :
https://github.com/nextcloud/activity/blob/2c6ec88c465ff79342b6c5ffbce03625f10f08e4/lib/Data.php#L124

There is no check when doing the insert into activity_mq

So we get an exception thrown if activity fails to create and entry in activity_mq, but we currently don't do anything with it. I'll see if we can trigger an activity without the description content in such cases then.

not exactly ,activity is created created in activity_mq, but description is truncated.
So it result in a broken JSON, which can't be exploited by the mailing queue.

Hello @mamatt . Is there a (system-wide) way to prevent the activity app from gathering notifications from Deck? This bug is preventing our server from sending any emails. I can clear periodically the Deck entries from the activity_mq table by hand, but that's a bit of a hack...

As far as I know there is no such thing.
By the way, we have exactly the same issue and it's very annoying.

Are you also seeing an issue with this in the activity stream or is it just related to the mails?

This is only for mail as in the DB the subjectparams field from activity_mq is limited to 4000 chars where the subjectparams from
activity message is text field.

The real issue is when copying from activity to activity_mq because an invalid json is pushed to the DB :
-> https://github.com/nextcloud/activity/blob/2c6ec88c465ff79342b6c5ffbce03625f10f08e4/lib/Data.php#L124

However the error is raised when only when activity queue try to re-read the json.

This a really a serious issue as it break all nextcloud activity mail, not only deck ones.

Is there an issue in the activity app already for this?

Why is this closed? Is there a follow up issue?

Well as linked this is mainly fixed by https://github.com/nextcloud/deck/pull/2117

The size of the activity_mq table was fixed with https://github.com/nextcloud/activity/pull/509

Is there any issue with this still please open a new issue

Was this page helpful?
0 / 5 - 0 ratings

Related issues

fm-sys picture fm-sys  路  4Comments

langfingaz picture langfingaz  路  3Comments

funky123 picture funky123  路  4Comments

poVoq picture poVoq  路  4Comments

RobertZenz picture RobertZenz  路  4Comments