TypeError: Argument 7 passed to OCA-Mail-Controller-MessagesController

Nextcloud version (eg, 20.0.5): 20.0.7
Operating system and version (eg, Ubuntu 20.04): Debian 10
Apache or nginx version (eg, Apache 2.4.25): Nginx
PHP version (eg, 7.4): 7.4

The issue you are facing: Don’t like PHP errors in my log )-:

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

Steps to replicate it:

  1. If only I knew…

The output of your Nextcloud log in Admin > Logging (at time 11:20:57):

Error	index	TypeError: Argument 7 passed to OCA\Mail\Controller\MessagesController::__construct() must be of the type string, null given

    <<closure>>

    OCA\Mail\Controller\MessagesController->__construct()

    /var/www/vhosts/{domain}/lib/private/AppFramework/Utility/SimpleContainer.php - line 101:

    ReflectionClass->newInstanceArgs()

    /var/www/vhosts/{domain}/lib/private/AppFramework/Utility/SimpleContainer.php - line 109:

    OC\AppFramework\Utility\SimpleContainer->buildClass()

    /var/www/vhosts/{domain}/lib/private/AppFramework/Utility/SimpleContainer.php - line 126:

    OC\AppFramework\Utility\SimpleContainer->resolve()

    /var/www/vhosts/{domain}/lib/private/AppFramework/DependencyInjection/DIContainer.php - line 455:

    OC\AppFramework\Utility\SimpleContainer->query()

    /var/www/vhosts/{domain}/lib/private/AppFramework/DependencyInjection/DIContainer.php - line 427:

    OC\AppFramework\DependencyInjection\DIContainer->queryNoFallback()

    /var/www/vhosts/{domain}/lib/private/AppFramework/App.php - line 139:

    OC\AppFramework\DependencyInjection\DIContainer->query()

    /var/www/vhosts/{domain}/lib/private/Route/Router.php - line 309:

    OC\AppFramework\App::main()

    /var/www/vhosts/{domain}lib/base.php - line 1008:

    OC\Route\Router->match()

    /var/www/vhosts/{domain}/index.php - line 37:

    OC::handleRequest()

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

$CONFIG = array (

  'instanceid' => 'ocffdna555s0',
  'passwordsalt' => 'GmhtCzmiaVb1nG6y1IkXGTwkSUdUiT',
  'secret' => '8WdpMBL3G6GvhS0WT0eaPm55m3ARQa08qkrZmTJZ6XSEX8kj',

  'trusted_domains' => [
    '{domain}',
  ],
  'datadirectory' => '/var/www/vhosts/{domain}/oc-data',
  'overwrite.cli.url' => 'https://{domain}',

  'dbtype' => 'mysql',
  'version' => '20.0.7.1',
  'dbname' => '{domain}',
  'dbhost' => 'localhost',
  'dbtableprefix' => 'oc_',
  'dbuser' => '{domain}',
  'dbpassword' => 'blabla',

  'logtimezone' => 'UTC',
  'installed' => true,
  'loglevel' => 2,
  'forcessl' => true,
  'theme' => '',
  'maintenance' => false,

  'mail_from_address' => 'webmaster',
  'mail_domain' => '{domain}',
  'mail_smtpmode' => 'sendmail',


  /* Enable SMTP class debugging */
  'mail_smtpdebug' => false,
  /* Which mode to use for sending mail: 'sendmail', 'smtp' or 'qmail' */
  // 'mail_smtpmode' => 'smtp',
  'mail_smtphost' => '127.0.0.1',
  'mail_smtpport' => 25,
  'mail_smtptimeout' => 10,
  /* Specify when you are using 'ssl' for SSL/TLS or 'tls' for STARTTLS, or leave empty for no encryption */
  'mail_smtpsecure' => '',
  /* Change this to 'true' if your mail server requires authentication */
  'mail_smtpauth' => false,
  'mail_smtpauthtype' => 'LOGIN',
  'mail_smtpname' => '',
  'mail_smtppassword' => '',


  'default_language' => 'en',
  'log_rotate_size' => 10485760,
  'check_for_working_htaccess' => false,

  'preview_libreoffice_path' => '/usr/bin/libreoffice',
  'preview_max_x' => 512,
  'preview_max_y' => 512,
  'preview_max_scale_factor' => 1,
  'preview_max_filesize_image' => 10,
  'enabledPreviewProviders' => [
	'OC\Preview\PNG',
	'OC\Preview\JPEG',
	'OC\Preview\GIF',
	'OC\Preview\HEIC',
	'OC\Preview\BMP',
	'OC\Preview\XBitmap',
	'OC\Preview\MP3',
	'OC\Preview\TXT',
	'OC\Preview\MarkDown',
	'OC\Preview\OpenDocument',
	'OC\Preview\Krita',
	'OC\Preview\PDF',
  ],

  'openssl' => array (
    'config' => '/etc/ssl/openssl.cnf',
  ),

  'memcache.local' => '\OC\Memcache\APCu',  // Has one 32M segment


/**
 * Enables transactional file locking.
 * This is enabled by default.
 *
 * Prevents concurrent processes from accessing the same files
 * at the same time. Can help prevent side effects that would
 * be caused by concurrent operations. Mainly relevant for
 * very large installations with many users working with
 * shared files.
 *
 * Defaults to ``true``
 */
'filelocking.enabled' => true,

/**
 * Set the lock's time-to-live in seconds.
 *
 * Any lock older than this will be automatically cleaned up.
 *
 * Defaults to ``60*60`` seconds (1 hour) or the php
 *             max_execution_time, whichever is higher.
 */
'filelocking.ttl' => 60*60,

/**
 * Memory caching backend for file locking
 *
 * Because most memcache backends can clean values without warning using redis
 * is highly recommended to *avoid data loss*.
 *
 * Defaults to ``none``
 */
'memcache.locking' => '\\OC\\Memcache\\Redis',

  'redis' => [
	'host' => '/var/run/redis/redis-server.sock',
	'port' => 0,
	'timeout'  => 1.5,
	'password' => '',	// Optional, if not defined no password will be used.
	'dbindex'  => 1,	// Optional, if undefined SELECT will not run and will use Redis Server's default DB Index.
  ],

  'trashbin_retention_obligation' => 'auto',
  'enable_avatars' => true,
  'allow_user_to_change_display_name' => true,
  'check_for_working_wellknown_setup' => false,
  'appstore.experimental.enabled' => true,

  'updater.release.channel' => 'stable',
  'updater.secret' => '$2y$10$2qNalF6afqwFdSY3CE74kuTE3n7xbh8y.lEcOu2Iyv29kCiSaVZMa',

  'blacklisted_files' => [
  ],

);

The output of your Apache/nginx/system log in /var/log/____ at time 11:20:57 - so it was either the heartbeat or a mailbox sync:

94.31.81.140 - - [05/Feb/2021:11:20:57 +0100] "PUT /apps/user_status/heartbeat HTTP/2.0" 401 43 "https://owncloud.sat-chit-ananda.org/apps/mail/box/191/thread/17110" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:84.0) Gecko/20100101 Firefox/84.0"

94.31.81.140 - - [05/Feb/2021:11:20:57 +0100] "POST /apps/mail/api/mailboxes/265/sync HTTP/2.0" 401 43 "https://owncloud.sat-chit-ananda.org/apps/mail/box/191/thread/17110" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:84.0) Gecko/20100101 Firefox/84.0"

94.31.81.140 - - [05/Feb/2021:11:20:57 +0100] "POST /apps/mail/api/mailboxes/191/sync HTTP/2.0" 401 43 "https://owncloud.sat-chit-ananda.org/apps/mail/box/191/thread/17110" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:84.0) Gecko/20100101 Firefox/84.0"

94.31.81.140 - - [05/Feb/2021:11:20:57 +0100] "POST /apps/mail/api/mailboxes/270/sync HTTP/2.0" 401 43 "https://owncloud.sat-chit-ananda.org/apps/mail/box/191/thread/17110" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:84.0) Gecko/20100101 Firefox/84.0"

94.31.81.140 - - [05/Feb/2021:11:20:57 +0100] "GET /csrftoken HTTP/2.0" 200 123 "https://owncloud.sat-chit-ananda.org/apps/mail/box/191/thread/17110" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:84.0) Gecko/20100101 Firefox/84.0"

94.31.81.140 - - [05/Feb/2021:11:20:57 +0100] "GET /apps/mail/api/messages?mailboxId=185&limit=20 HTTP/2.0" 500 4189 "https://owncloud.sat-chit-ananda.org/apps/mail/box/191/thread/17110" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:84.0) Gecko/20100101 Firefox/84.0"