Update from 25.0.3 to 25.0.4 stuck "Unable to generate a URL for the named route"

Nextcloud version (eg, 20.0.5): Update from 25.0.3 to 25.0.4
Operating system and version (eg, Ubuntu 20.04): Linux, supplied by hoster
Apache or nginx version (eg, Apache 2.4.25): Apache
PHP version (eg, 7.4): 8.x

The issue you are facing:
I was updating from 25.0.3 to 25.0.4 via the web interface (we do not have shell access)

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

Steps to replicate it:
I tried to re-run the update by re-setting the maintenance mode, and now repeatably get:
Message in Browser:

Update vorbereiten
Log-Level auf "debug" gesetzt
Wartungsmodus eingeschaltet
Reparaturschritt: Repair MySQL collation
Reparaturinformation: All tables already have the correct collation -> nothing to do
Reparaturschritt: Repair SQLite autoincrement
Reparaturschritt: Copy data from accounts table when migrating from ownCloud
Reparaturschritt: Drop account terms table when migrating from ownCloud
Das Datenbankschema wird aktualisiert
Datenbank aktualisiert
Es ist ein Fehler aufgetreten.

The output of your Nextcloud log in Admin > Logging:
first line of update run

{"reqId":"ZAS_lfEgqD_S9Ay_txNwKwAAZh4","level":1,"time":"2023-03-05T16:13:09+00:00","remoteAddr":"","user":"--","app":"no app in context","method":"GET","url":"/","message":"Unable to generate a URL for the named route \"cloud_federation_api.RequestHandler.addShare\" as such route does not exist.","userAgent":"Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/110.0","version":"","exception":{"Exception":"Symfony\\Component\\Routing\\Exception\\RouteNotFoundException","Message":"Unable to generate a URL for the named route \"cloud_federation_api.RequestHandler.addShare\" as such route does not exist.","Code":0,"Trace":[{"file":"/www/htdocs/w0172344/cloud/htdocs_25.0.4/lib/private/Route/Router.php","line":361,"function":"generate","class":"Symfony\\Component\\Routing\\Generator\\UrlGenerator","type":"->","args":["cloud_federation_api.RequestHandler.addShare",[],1]},{"file":"/www/htdocs/w0172344/cloud/htdocs_25.0.4/lib/private/URLGenerator.php","line":103,"function":"generate","class":"OC\\Route\\Router","type":"->","args":["cloud_federation_api.RequestHandler.addShare",[]]},{"file":"/www/htdocs/w0172344/cloud/htdocs_25.0.4/lib/private/URLGenerator.php","line":115,"function":"linkToRoute","class":"OC\\URLGenerator","type":"->","args":["cloud_federation_api.requesthandlercontroller.addShare",[]]},{"file":"/www/htdocs/w0172344/cloud/htdocs_25.0.4/apps/cloud_federation_api/lib/Capabilities.php","line":44,"function":"linkToRouteAbsolute","class":"OC\\URLGenerator","type":"->","args":["cloud_federation_api.requesthandlercontroller.addShare"]},{"file":"/www/htdocs/w0172344/cloud/htdocs_25.0.4/lib/private/CapabilitiesManager.php","line":75,"function":"getCapabilities","class":"OCA\\CloudFederationAPI\\Capabilities","type":"->","args":[]},{"file":"/www/htdocs/w0172344/cloud/htdocs_25.0.4/lib/private/Template/JSConfigHelper.php","line":166,"function":"getCapabilities","class":"OC\\CapabilitiesManager","type":"->","args":[false,true]},{"file":"/www/htdocs/w0172344/cloud/htdocs_25.0.4/lib/private/TemplateLayout.php","line":229,"function":"getConfig","class":"OC\\Template\\JSConfigHelper","type":"->","args":[]},{"file":"/www/htdocs/w0172344/cloud/htdocs_25.0.4/lib/private/legacy/OC_Template.php","line":184,"function":"__construct","class":"OC\\TemplateLayout","type":"->","args":["guest",""]},{"file":"/www/htdocs/w0172344/cloud/htdocs_25.0.4/lib/private/Template/Base.php","line":132,"function":"fetchPage","class":"OC_Template","type":"->","args":[]},{"file":"/www/htdocs/w0172344/cloud/htdocs_25.0.4/lib/base.php","line":414,"function":"printPage","class":"OC\\Template\\Base","type":"->","args":[]},{"file":"/www/htdocs/w0172344/cloud/htdocs_25.0.4/lib/base.php","line":997,"function":"printUpgradePage","class":"OC","type":"::","args":[["OC\\SystemConfig"]]},{"file":"/www/htdocs/w0172344/cloud/htdocs_25.0.4/index.php","line":36,"function":"handleRequest","class":"OC","type":"::","args":[]}],"File":"/www/htdocs/w0172344/cloud/htdocs_25.0.4/3rdparty/symfony/routing/Generator/UrlGenerator.php","Line":143,"message":"Unable to generate a URL for the named route \"cloud_federation_api.RequestHandler.addShare\" as such route does not exist.","exception":{},"CustomMessage":"Unable to generate a URL for the named route \"cloud_federation_api.RequestHandler.addShare\" as such route does not exist."}}

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

$CONFIG = array (
  'instanceid' => 'XXXXX',
  'passwordsalt' => 'XXXXX',
  'secret' => 'XXXXX',
  'trusted_domains' => 
  array (
    0 => 'cloud.swensk-ton.de',
  'datadirectory' => '/XXXXX/cloud/data',
  'overwrite.cli.url' => 'http://cloud.swensk-ton.de',
  'dbtype' => 'mysql',
  'version' => '',
  'dbname' => 'd0276d10',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'muDM8_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'XXXX',
  'dbpassword' => 'XXXXX',
  'installed' => true,
  'tempdirectory' => 'XXXXX/tmp/',
  'maintenance' => false,
  'theme' => '',
  'loglevel' => 0,
  'mail_from_address' => 'webmaster',
  'mail_smtpmode' => 'smtp',
  'mail_domain' => 'swensk-ton.de',
  'updater.release.channel' => 'stable',
  'mail_smtphost' => 'XXXXX',
  'mail_sendmailmode' => 'smtp',
  'mail_smtpauth' => 1,
  'mail_smtpauthtype' => 'LOGIN',
  'mail_smtpname' => 'XXXXX',
  'mail_smtppassword' => 'XXXXX',
  'mail_smtpport' => '587',
  'default_language' => 'de',
  'default_phone_region' => 'DE',
  'app_install_overwrite' => 
  array (
    0 => 'occweb',

The full log is available at https://www.swensk-ton.de/nextcloud.log

in your log files it looks like it’s heavily related to the password_policies app. Maybe you could try disabling this app and retrying the update, and enabling it again?

edit hm also quite some errors to theming, which reminds me of Upgrade to 24.0.4 failed - #6 by romainrossi

I also had this issue with the upgrade from 25.0.3 to 25.0.4. I disabled a bunch of apps and eventually I was able to get back in.

It may have been disabling the maps or news app that finally did the trick.

sudo -u www-data php occ app:disable maps

Just do sudo -u www-data php occ app:list to see what you can disable. Or go down the nextcloud.log file and disable the ones that you can listed there.

They seem to be fine after I reenable them in the web interface.

My problem is that I do not have shell access on this machine and can therefore not use occ.

  1. I reverted to download everything (all files, database) to my personal Linux system.
  2. I set up a database and run occ update.
  3. I uploaded the changed config.php and the database back to the server. Nextcloud started, but many Apps were not active.
    The APp Store was an empty white page.
  4. I deactivated some apps on my local installation and uploaded the database again.
  5. At some stage the App Store was back. Many Apps were active, but at version number “0”. → They were active, but not installed. That happens on many updates.
  6. I experimented with adding more memory to PHP. I believe now that too low memory was the root cause of the failure.

After a longer evening session, my cloud is now back in business!
Thanks to @Daphne and @nickt for their inputs.