TypeError: Cannot access offset of type string on string in MigrateBackgroundImages.php

Today, after having upgraded to nextcloud 25.0.2 about 2 days ago, i received an E-mail from the next cloud cron job:

TypeError: Cannot access offset of type string on string in /home/nextcloud/httpd/www/html/nextcloud/apps/theming/lib/Jobs/MigrateBackgroundImages.php:74
Stack trace:
#0 /home/nextcloud/httpd/www/html/nextcloud/lib/public/BackgroundJob/Job.php(78): OCA\Theming\Jobs\MigrateBackgroundImages->run()
#1 /home/nextcloud/httpd/www/html/nextcloud/lib/public/BackgroundJob/QueuedJob.php(58): OCP\BackgroundJob\Job->start()
#2 /home/nextcloud/httpd/www/html/nextcloud/lib/public/BackgroundJob/QueuedJob.php(48): OCP\BackgroundJob\QueuedJob->start()
#3 /home/nextcloud/httpd/www/html/nextcloud/cron.php(152): OCP\BackgroundJob\QueuedJob->execute()
#4 {main}

[/details]

Nextcloud version: 25.0.2
Operating system and version: Fedora 37
Apache or nginx version: 2.4.54
PHP version: 8.1.13

The issue you are facing:
I received the mail noted down above. Don’t know, if the job failed. When i run it manually, i get no error message. Probably it happened only one time after the upgrade of nextcloud to 25.0.2 ? But since the upgrade this cron job has run a lot of times already without emitting the error.

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

Steps to replicate it:

  1. Upgrade to nextcloud 25.0.2
  2. let the cron job run several times (don’t know, how often is required), don’t know if this will ever happen again

The output of your Nextcloud log in Admin > Logging:
There are no logs “everything is working fine”

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

<?php
$CONFIG = array (
  'default_phone_region' => 'DE',
  'log_type' => 'syslog',
  'datadirectory' => '/home/nextcloud/httpd/var/lib/nextcloud/data',
  'updatechecker' => false,
  'check_for_working_htaccess' => false,
  'asset-pipeline.enabled' => false,
  'assetdirectory' => '/home/nextcloud/httpd/var/lib',
  'preview_libreoffice_path' => '/usr/bin/libreoffice',
  'apps_paths' => 
  array (
    0 => 
    array (
      'path' => '/home/nextcloud/httpd/www/html/nextcloud/apps',
      'url' => '/apps',
      'writable' => false,
    ),
    1 => 
    array (
      'path' => '/home/nextcloud/httpd/var/lib/nextcloud/apps',
      'url' => '/apps-appstore',
      'writable' => true,
    ),
  ),
  'trusted_domains' => 
  array (
    0 => 'fqdn.1',
    1 => 'fqdn.2',
    2 => 'fqdn.3',
    3 => 'fqdn.4',
    4 => 'localhost',
    5 => 'localhost6',
  ),
  'trusted_proxies' => 
  array (
    0 => 'localhost',
    1 => '::1',
    2 => '127.0.0.1',
    3 => 'localhost6',
  ),
  'overwrite.cli.url' => 'http://localhost:4928/nextcloud',
  'overwriteprotocol' => 'https',
  'theme' => '',
  'loglevel' => 9,
  'maintenance' => false,
  'instanceid' => 'instance-id',
  'passwordsalt' => 'my-salt',
  'secret' => 'my-secret',
  'dbtype' => 'mysql',
  'version' => '25.0.2.3',
  'dbname' => 'my-db-name,
  'dbhost' => 'my-db-host,
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'nextcloud',
  'dbpassword' => 'my-db-password',
  'installed' => true,
  'mail_from_address' => 'nextcloud',
  'mail_smtpmode' => 'smtp',
  'mail_sendmailmode' => 'smtp',
  'mail_domain' => 'my-domain',
  'mail_smtphost' => 'my-smtp-host,
  'mail_smtpport' => '25',
  'updater.release.channel' => 'stable',
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'updater.secret' => '...',
);

The output of your Apache/nginx/system log in /var/log/____:
there is no output caused by this cron job.

Output errors in nextcloud.log in /var/www/ or as admin user in top right menu, filtering for errors. Use a pastebin service if necessary.
no output has been caused by this cron job, all i have is the content of the mail (see above)

Around line 74 of MigrateBackgroundImages.php i see:
protected function run($argument): void {
if (!isset($argument[‘stage’])) {
// not executed in 25.0.0?!
$argument[‘stage’] = self::STAGE_PREPARE;
}

Frankly i do not have sufficient insight and overview. Could it be
the run method is called with an uninitialized argument ? Then it might help to assign an empty array as default like this:
protected function run($argument = ): void {

Following up the stack trace and looking at /lib/public/BackgroundJob/Job.php
abstract class Job implements IJob {
protected int $id = 0;
protected int $lastRun = 0;
protected $argument;

there is no default value. Unless the method setArgument is called, $argument remains unset. Could this be the issue ?
Someone else reported an error in the logs and webdav being broken. It might be the same. Thank you for helping.

See [theming] TypeError: Cannot access offset of type string on string in MigrateBackgroundImages.php · Issue #35921 · nextcloud/server · GitHub , it will be fixed in 25.0.3