Htmlspecialchars() error in log every morning

Nextcloud version (eg, 20.0.5): 20.0.8
Operating system and version (eg, Ubuntu 20.04): Linux 4.15.0-140-generic x86_64 (no more information because it is a hosted environment)
Apache or nginx version (eg, Apache 2.4.25): Unknown (hosted environment)
PHP version (eg, 7.4): 7.4.14

The issue you are facing:
I see the following error in the nextcloud log every morning between 6-10am since a week:
TypeError: htmlspecialchars() expects parameter 1 to be string, null given
In the details of this error is an e-mail-address. It is the same e-mail-address of one of my users every day.

Is this the first time you’ve seen this error? (Y/N): Y

The output of your Nextcloud log in Admin > Logging:

[activity] Error: TypeError: htmlspecialchars() expects parameter 1 to be string, null given at <<closure>>

0. /nextcloud/apps/activity/lib/DigestSender.php line 239
   htmlspecialchars(null)
1. /nextcloud/apps/activity/lib/DigestSender.php line 193
   OCA\Activity\DigestSender->getHTMLSubject(OC\Activity\Event {})
2. /nextcloud/apps/activity/lib/DigestSender.php line 112
   OCA\Activity\DigestSender->sendDigestForUser("example@example", 1617167402, "Europe/Berlin", "de")
3. /nextcloud/apps/activity/lib/BackgroundJob/DigestMail.php line 47
   OCA\Activity\DigestSender->sendDigests(1617167402)
4. /nextcloud/lib/private/BackgroundJob/Job.php line 52
   OCA\Activity\BackgroundJob\DigestMail->run(null)
5. /nextcloud/lib/private/BackgroundJob/TimedJob.php line 59
   OC\BackgroundJob\Job->execute(OC\BackgroundJob\JobList {}, OC\Log {})
6. /nextcloud/cron.php line 149
   OC\BackgroundJob\TimedJob->execute(OC\BackgroundJob\JobList {}, OC\Log {})

GET /cron.php
from IP-Address at 2021-03-31T05:10:04+00:00

The output of your config.php file in /path/to/nextcloud (make sure you remove any identifiable information!):

<?php
$CONFIG = array (
  'instanceid' => 'id',
  'passwordsalt' => 'passwordsalt',
  'secret' => 'secret',
  'trusted_domains' => 
  array (
    0 => 'example.example.com',
    1 => 'www.example.example.com',
  ),
  'datadirectory' => '/nextcloud/data',
  'dbtype' => 'mysql',
  'version' => '20.0.8.1',
  'overwrite.cli.url' => 'https://example.example.com/',
  'dbname' => 'dbname',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'db_prefix',
  'mysql.utf8mb4' => true,
  'dbuser' => 'dbuser',
  'dbpassword' => 'dbpassword',
  'installed' => true,
  'tempdirectory' => '/nextcloud/tmp/',
  'mail_smtpmode' => 'sendmail',
  'mail_sendmailmode' => 'pipe',
  'mail_from_address' => 'example',
  'mail_domain' => 'example.com',
  'maintenance' => false,
  'theme' => '',
  'loglevel' => 2,
  'htaccess.RewriteBase' => '/',
  'simpleSignUpLink.shown' => false,
  'default_language' => 'de',
  'default_locale' => 'de_DE',
  'skeletondirectory' => '',
);

The output of your Apache/nginx/system log in /var/log/____:

Not accessible

Hi nilskamm,

looking at the log entry you provided, it looks like the setup Cronjob is creating this log entry. Since it also mentions getHTMLSubject(OC\Activity\Event {}) and an email address, I guess it has something to do with the activity feature of Nextcloud.

The setting can be found under User settings (click on the avatar and chose settings) -> Activity -> Send daily activity summary in the morning (checkbox at the bottom)

The error itself is telling us, that the function htmlspecialchars() is expecting the parameter 1 to be a string but nothing / null has been given.

You say this appears every morning in your Nextcloud logs? Is it always the same email address, or are there more email addresses involved?

Since it is a hosted system, I guess there is no way to check the Cron-/Apache logs? Maybe you could ask your provider, if there is any chance for you to look into these logs, as these would probably give us more information.

Hey @CFelix
Thanks a lot for your answer!
I know it is a long time, but life did things more important than an error-message without any impact.

You are right! It comes from the “Send daily activity summary in the morning”.
After activating this checkbox i get two error messages each day. One for my e-mail address, one of another user. I could see in the database, that we are the only user who have this option activated.

I could also see, that the error message only shows up, if there is no mail. On days where we get mails with activities, the error message does not exist.

So i guess this is already the whole problem.
If there are activities the mails are sent and if not, the error shows up in the error-log.

I cannot get any other logs from the provider.

I just don´t know if this is a bug in nextcloud everyone would have or if it is just in our instance.
Is there a way anyone can check if they get this error if they have this option activated but don´t have any activities?

Thanks a lot!