Nextcloud snap, config set failed, now snap commands don't work and nextcloud down

I had the problem that new nextcloud clients cannot connect to my nextcloud server (snap, version 14) (the client login loop problem. In a forum thread I read that I had to set overwriteprotocol.
So I executed the following command:

snap run nextcloud.occ config:system:set overwriteprotocol ‘https’

This returned with:

System config value overwriteprotocol => https set to empty string

And now any command I run will throw an error:

snap run nextcloud.occ config:system:get overwriteprotocol

An unhandled exception has been thrown:
TypeError: Return value of OC\AppFramework\Http\Request::getServerProtocol() must be of the type string, array returned in /snap/nextcloud/11755/htdocs/lib/private/AppFramework/Http/Request.php:649
Stack trace:
#0 /snap/nextcloud/11755/htdocs/lib/private/URLGenerator.php(253): OC\AppFramework\Http\Request->getServerProtocol()
#1 /snap/nextcloud/11755/htdocs/lib/private/Template/SCSSCacher.php(114): OC\URLGenerator->getBaseUrl()
#2 /snap/nextcloud/11755/htdocs/lib/private/Server.php(970): OC\Template\SCSSCacher->__construct(Object(OC\Log), Object(OC\Files\AppData\Factory), Object(OC\URLGenerator), Object(OC\AllConfig), Object(OCA\Theming\ThemingDefaults), ‘/snap/nextcloud…’, Object(OC\Memcache\Factory), Object(OC\Template\IconsCacher), Object(OC\AppFramework\Utility\TimeFactory))
#3 /snap/nextcloud/11755/htdocs/3rdparty/pimple/pimple/src/Pimple/Container.php(118): OC\Server->OC{closure}(Object(OC\Server))
#4 /snap/nextcloud/11755/htdocs/lib/private/AppFramework/Utility/SimpleContainer.php(117): Pimple\Container->offsetGet(‘OC\Template\SCS…’)
#5 /snap/nextcloud/11755/htdocs/lib/private/ServerContainer.php(132): OC\AppFramework\Utility\SimpleContainer->query(‘OC\Template\SCS…’)
#6 /snap/nextcloud/11755/htdocs/lib/private/Repair.php(138): OC\ServerContainer->query(‘OC\Template\SCS…’)
#7 /snap/nextcloud/11755/htdocs/core/register_command.php(143): OC\Repair::getRepairSteps()
#8 /snap/nextcloud/11755/htdocs/lib/private/Console/Application.php(118): require_once(’/snap/nextcloud…’)
#9 /snap/nextcloud/11755/htdocs/console.php(95): OC\Console\Application->loadCommands(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#10 /snap/nextcloud/11755/htdocs/occ(11): require_once(’/snap/nextcloud…’)
#11 {main}root@nextcloud:/snap/nextcloud/current/htdocs/config# snap run nextcloud.occ config:system:get overwriteprotocol.https
An unhandled exception has been thrown:
TypeError: Return value of OC\AppFramework\Http\Request::getServerProtocol() must be of the type string, array returned in /snap/nextcloud/11755/htdocs/lib/private/AppFramework/Http/Request.php:649
Stack trace:
#0 /snap/nextcloud/11755/htdocs/lib/private/URLGenerator.php(253): OC\AppFramework\Http\Request->getServerProtocol()
#1 /snap/nextcloud/11755/htdocs/lib/private/Template/SCSSCacher.php(114): OC\URLGenerator->getBaseUrl()
#2 /snap/nextcloud/11755/htdocs/lib/private/Server.php(970): OC\Template\SCSSCacher->__construct(Object(OC\Log), Object(OC\Files\AppData\Factory), Object(OC\URLGenerator), Object(OC\AllConfig), Object(OCA\Theming\ThemingDefaults), ‘/snap/nextcloud…’, Object(OC\Memcache\Factory), Object(OC\Template\IconsCacher), Object(OC\AppFramework\Utility\TimeFactory))
#3 /snap/nextcloud/11755/htdocs/3rdparty/pimple/pimple/src/Pimple/Container.php(118): OC\Server->OC{closure}(Object(OC\Server))
#4 /snap/nextcloud/11755/htdocs/lib/private/AppFramework/Utility/SimpleContainer.php(117): Pimple\Container->offsetGet(‘OC\Template\SCS…’)
#5 /snap/nextcloud/11755/htdocs/lib/private/ServerContainer.php(132): OC\AppFramework\Utility\SimpleContainer->query(‘OC\Template\SCS…’)
#6 /snap/nextcloud/11755/htdocs/lib/private/Repair.php(138): OC\ServerContainer->query(‘OC\Template\SCS…’)
#7 /snap/nextcloud/11755/htdocs/core/register_command.php(143): OC\Repair::getRepairSteps()
#8 /snap/nextcloud/11755/htdocs/lib/private/Console/Application.php(118): require_once(’/snap/nextcloud…’)
#9 /snap/nextcloud/11755/htdocs/console.php(95): OC\Console\Application->loadCommands(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#10 /snap/nextcloud/11755/htdocs/occ(11): require_once(’/snap/nextcloud…’)
#11 {main}root@nextcloud:/snap/nextcloud/current/htdocs/config#

I tried to update to version 15
snap refresh nextcloud --channel=latest/stable
Which seemingly went fine, but still no nextcloud running.

What did I do wrong and how can I fix this.
My whole server is down.

cc @kyrofa

This doesn’t have anything to do with the snap-- you’re not using occ correctly (and occ doesn’t sanity check values, it seems). You should have run:

$ sudo nextcloud.occ config:system:set overwriteprotocol --value 'https'

See sudo nextcloud.occ config:system:set --help for the details, but to unblock you, do this:

Open up your config (as root) in your favorite editor, the file is located at /var/snap/nextcloud/current/nextcloud/config/config.php. Find the overwriteprotocol and you’ll notice that it’s an array instead of a string:

// ...
'overwriteprotocol' =>
  array (
    'https' => '',
  ),
// ...

Change those lines to look like this:

// ...
'overwriteprotocol' => 'https',
// ...
1 Like

Sorry, didn’t read the question properly. :roll_eyes:

@kyrofa
Thank you for the detailed answer. It helped a lot :slight_smile:

I had an inkling on what would be wrong but I could not find the correct file to edit (nextcloud is the only snap I actually use).