Cannot delete/unshare directory from remote nextcloud that doesnt exist anymore

Nextcloud version (eg, 12.0.2): 17
Operating system and version (eg, Ubuntu 17.04): Gentoo Linux
Apache or nginx version (eg, Apache 2.4.25):
PHP version (eg, 7.1):

The issue you are facing: I’ve got a share from remote NextCloud, but the remote server doesn’t exists anymore. I still got a share from that nonexisting server. When I’m trying to delete the share it gives me an error.

Not sure if this is important, but the share has polish letter “ź” (Udźal). It seems that in the log it is “Udźal” and “Ud%C5%BAal”.

Is this the first time you’ve seen this error? No, same was on nc16.

Steps to replicate it as I suppose:

  1. Make a share from server nc_1 to server nc_2.
  2. Shutdown the nc_1 server.
  3. Try to remove a share from nc_2.

The output of your Nextcloud log in Admin > Logging:

{"reqId":"XeoF43M5MIYbeJmYpU7DxQAAAAo","level":4,"time":"2019-12-06T07:40:19+00:00","remoteAddr":"89.66.149.2","user":"ncuser","app":"webdav","method":"DELETE","url":"/remote.php/dav/files/ncuser/Ud%C5%BAal","message":{"Exception":"Sabre\\DAV\\Exception\\ServiceUnavailable","Message":"","Code":0,"Trace":[{"file":"/var/www/nc.mojadomena.eu/htdocs/3rdparty/sabre/dav/lib/DAV/Tree.php","line":76,"function":"getChild","class":"OCA\\DAV\\Connector\\Sabre\\Directory","type":"->","args":["Udźal"]},{"file":"/var/www/nc.mojadomena.eu/htdocs/3rdparty/sabre/dav/lib/DAV/Tree.php","line":178,"function":"getNodeForPath","class":"Sabre\\DAV\\Tree","type":"->","args":["files/ncuser/Udźal"]},{"file":"/var/www/nc.mojadomena.eu/htdocs/3rdparty/sabre/dav/lib/DAV/CorePlugin.php","line":287,"function":"delete","class":"Sabre\\DAV\\Tree","type":"->","args":["files/ncuser/Udźal"]},{"function":"httpDelete","class":"Sabre\\DAV\\CorePlugin","type":"->","args":[{"absoluteUrl":"https://nc.mojadomena.eu/remote.php/dav/files/ncuser/Ud%C5%BAal","__class__":"Sabre\\HTTP\\Request"},{"__class__":"Sabre\\HTTP\\Response"}]},{"file":"/var/www/nc.mojadomena.eu/htdocs/3rdparty/sabre/event/lib/EventEmitterTrait.php","line":105,"function":"call_user_func_array","args":[[{"__class__":"Sabre\\DAV\\CorePlugin"},"httpDelete"],[{"absoluteUrl":"https://nc.mojadomena.eu/remote.php/dav/files/ncuser/Ud%C5%BAal","__class__":"Sabre\\HTTP\\Request"},{"__class__":"Sabre\\HTTP\\Response"}]]},{"file":"/var/www/nc.mojadomena.eu/htdocs/3rdparty/sabre/dav/lib/DAV/Server.php","line":479,"function":"emit","class":"Sabre\\Event\\EventEmitter","type":"->","args":["method:DELETE",[{"absoluteUrl":"https://nc.mojadomena.eu/remote.php/dav/files/ncuser/Ud%C5%BAal","__class__":"Sabre\\HTTP\\Request"},{"__class__":"Sabre\\HTTP\\Response"}]]},{"file":"/var/www/nc.mojadomena.eu/htdocs/3rdparty/sabre/dav/lib/DAV/Server.php","line":254,"function":"invokeMethod","class":"Sabre\\DAV\\Server","type":"->","args":[{"absoluteUrl":"https://nc.mojadomena.eu/remote.php/dav/files/ncuser/Ud%C5%BAal","__class__":"Sabre\\HTTP\\Request"},{"__class__":"Sabre\\HTTP\\Response"}]},{"file":"/var/www/nc.mojadomena.eu/htdocs/apps/dav/lib/Server.php","line":317,"function":"exec","class":"Sabre\\DAV\\Server","type":"->","args":[]},{"file":"/var/www/nc.mojadomena.eu/htdocs/apps/dav/appinfo/v2/remote.php","line":35,"function":"exec","class":"OCA\\DAV\\Server","type":"->","args":[]},{"file":"/var/www/nc.mojadomena.eu/htdocs/remote.php","line":163,"args":["/var/www/nc.mojadomena.eu/htdocs/apps/dav/appinfo/v2/remote.php"],"function":"require_once"}],"File":"/var/www/nc.mojadomena.eu/htdocs/apps/dav/lib/Connector/Sabre/Directory.php","Line":225,"CustomMessage":"--"},"userAgent":"Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36","version":"17.0.1.1","id":"5dea0705d0bf4"}

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

<?php
$CONFIG = array (
  'instanceid' => 'foo',
  'passwordsalt' => 'bar',
  'secret' => 'baz',
  'trusted_domains' =>
  array (
    0 => 'nc.mojadomena.eu',
  ),
  'datadirectory' => '/var/www/nc.mojadomena.eu/htdocs/data',
  'dbtype' => 'pgsql',
  'version' => '17.0.1.1',
  'overwrite.cli.url' => 'https://nc.mojadomena.eu',
  'dbname' => 'foobar',
  'dbhost' => 'bazbar',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'dbuser' => 'bazfoo',
  'dbpassword' => 'foobaz',
  'installed' => true,
  'mail_smtpmode' => 'sendmail',
  'mail_sendmailmode' => 'smtp',
  'mail_from_address' => 'mojadomena',
  'mail_domain' => 'nc.mojadomena.eu',
  'theme' => '',
  'loglevel' => 2,
  'maintenance' => false,
  'app_install_overwrite' =>
  array (
    0 => 'spreed',
  ),
  'preview_max_x' => '2048',
  'preview_max_y' => '2048',
  'jpeg_quality' => '60',
);

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

89.66.149.2 - - [06/Dec/2019:09:03:12 +0100] "DELETE /remote.php/dav/files/ncuser/Ud%C5%BAal HTTP/1.1" 503 191
89.66.149.2 - - [06/Dec/2019:09:03:13 +0100] "GET /index.php/apps/files/ajax/getstoragestats.php HTTP/1.1" 200 233
89.66.149.2 - - [06/Dec/2019:09:03:13 +0100] "GET /index.php/apps/files/ajax/getstoragestats.php?dir=%2F HTTP/1.1" 200 233
89.66.149.2 - - [06/Dec/2019:09:03:07 +0100] "GET /index.php/apps/logreader/poll?lastReqId=XeoK-ikSy1Gj-HfWCE%404dgAAAAA HTTP/1.1" 200 3143
89.66.149.2 - - [06/Dec/2019:09:03:23 +0100] "GET /ocs/v2.php/apps/notifications/api/v2/notifications HTTP/1.1" 200 74
89.66.149.2 - - [06/Dec/2019:09:03:30 +0100] "DELETE /remote.php/dav/files/ncuser/Ud%C5%BAal HTTP/1.1" 503 191
89.66.149.2 - - [06/Dec/2019:09:03:30 +0100] "GET /index.php/apps/files/ajax/getstoragestats.php?dir=%2F HTTP/1.1" 200 233
89.66.149.2 - - [06/Dec/2019:09:03:14 +0100] "GET /index.php/apps/logreader/poll?lastReqId=XeoLQCkSy1Gj-HfWCE%404eAAAAAA HTTP/1.1" 200 3143
89.66.149.2 - - [06/Dec/2019:09:03:39 +0100] "GET /ocs/v2.php/apps/notifications/api/v2/notifications HTTP/1.1" 200 74
89.66.149.2 - - [06/Dec/2019:09:03:43 +0100] "GET /index.php/apps/files/ajax/getstoragestats.php HTTP/1.1" 200 233

I would assume that this problem has already been addressed here.

I saw those topics, but I consider them not as a solution, but as a workaround. Editing the database to remove a broken share seems overkill for an ordinary user.

PS Is this workaround working when your nc is encrypted? (just wondering)