External storage usage produces php error

Nextcloud version: 23.0.0
Operating system and version: Linux 5.4.0-91 running in Docker
Apache or nginx version: Apache/2.4.51
PHP version : 8.0.13

The issue you are facing:
I connected to a external storage via sftp when I try to create a file or folder it does create the folder or file but I get PHP errors telling me it tried to access a array offset on value of type bool (about five times the same error).
My ftp server is running vsftpd and connecting from the terminal works fine so
I would guess it’s a PHP problem?

Is this the first time you’ve seen this error?: Y

Steps to replicate it:

  1. Connect to external storage in nextcloud app over sftp using password and username
  2. Try to create a file or delete one in the external storage

The output of your Nextcloud log in Admin > Logging:

[PHP] Error: Trying to access array offset on value of type bool at /var/www/html/apps/files_external/lib/Lib/Storage/SFTP.php#330

MKCOL /remote.php/dav/files/USERNAME/SFTP/restore_points
from 31.164.225.151 by USERNAME at 2021-12-12T11:08:07+00:00

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

   <?php
$CONFIG = array (
  'htaccess.RewriteBase' => '/',
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'apps_paths' =>
  array (
    0 =>
    array (
      'path' => '/var/www/html/apps',
      'url' => '/apps',
      'writable' => false,
    ),
    1 =>
    array (
      'path' => '/var/www/html/custom_apps',
      'url' => '/custom_apps',
      'writable' => true,
    ),
  ),
  'memcache.distributed' => '\\OC\\Memcache\\Redis',
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'redis' =>
  array (
    'host' => 'redis',
    'password' => '',
    'port' => 6379,
  ),
  'instanceid' => ID,
  'passwordsalt' => SALT,
  'secret' => SECRET,
  'trusted_domains' =>
  array (
    0 => '192.168.1.98:8080',
    1 => DOMAIN,
  ),
  'datadirectory' => '/var/www/html/data',
  'dbtype' => 'pgsql',
  'version' => '23.0.0.10',
  'overwrite.cli.url' => 'http://192.168.1.98:8080',
  'overwriteprotocol' => 'https',
  'dbname' => 'nextcloud',
  'dbhost' => 'db',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'dbuser' => UESRNAME,
  'dbpassword' => PASSWORD,
  'installed' => true,
  'default_phone_region' => 'DE',
  'maintenance' => false,
);

here is the full Nextcloud error

/var/www/html/apps/files_external/lib/Lib/Storage/SFTP.php - line 334:

OC\Log\ErrorHandler::onError(2, "Trying to access array offset on value of type bool at /var/www/html/apps/files_external/lib/Lib/Storage/SFTP.php#334", "/var/www/ht ... p", 334)

/var/www/html/lib/private/Files/Storage/Common.php - line 114:

OCA\Files_External\Lib\Storage\SFTP->filetype("restore_points")

/var/www/html/lib/private/Files/Storage/Wrapper/Wrapper.php - line 114:

OC\Files\Storage\Common->is_dir("restore_points")

/var/www/html/lib/private/Files/Storage/Wrapper/Wrapper.php - line 114:

OC\Files\Storage\Wrapper\Wrapper->is_dir("restore_points")

/var/www/html/lib/private/Files/Storage/Wrapper/Availability.php - line 131:

OC\Files\Storage\Wrapper\Wrapper->is_dir("restore_points")

/var/www/html/lib/private/Files/Storage/Wrapper/Wrapper.php - line 114:

OC\Files\Storage\Wrapper\Availability->is_dir("restore_points")

/var/www/html/lib/private/Files/View.php - line 1171:

OC\Files\Storage\Wrapper\Wrapper->is_dir("restore_points")

/var/www/html/lib/private/Files/View.php - line 379:

OC\Files\View->basicOperation("is_dir", "/SFTP/restore_points")

/var/www/html/lib/private/Files/Filesystem.php - line 634:

OC\Files\View->is_dir("/SFTP/restore_points")

/var/www/html/lib/private/Files/Node/HookConnector.php - line 235:

OC\Files\Filesystem::is_dir("/SFTP/restore_points")

/var/www/html/lib/private/Files/Node/HookConnector.php - line 104:

OC\Files\Node\HookConnector->getNodeForPath("/SFTP/restore_points")

/var/www/html/lib/private/legacy/OC_Hook.php - line 106:

OC\Files\Node\HookConnector->write({ run: true, ... "})

/var/www/html/lib/private/Files/View.php - line 1284:

OC_Hook::emit("OC_Filesystem", "write", { run: true, ... "})

/var/www/html/lib/private/Files/View.php - line 1154:

OC\Files\View->runHooks([ "create","write"], "/SFTP/restore_points")

/var/www/html/lib/private/Files/View.php - line 271:

OC\Files\View->basicOperation("mkdir", "/SFTP/restore_points", [ "create","write"])

/var/www/html/apps/dav/lib/Connector/Sabre/Directory.php - line 188:

OC\Files\View->mkdir("/SFTP/restore_points")

/var/www/html/3rdparty/sabre/dav/lib/DAV/Server.php - line 1210:

OCA\DAV\Connector\Sabre\Directory->createDirectory("restore_points")

/var/www/html/3rdparty/sabre/dav/lib/DAV/CorePlugin.php - line 560:

Sabre\DAV\Server->createCollection("files/USERNAME/SFTP/restore_points", Sabre\DAV\MkCol {})

/var/www/html/3rdparty/sabre/event/lib/WildcardEmitterTrait.php - line 89:

Sabre\DAV\CorePlugin->httpMkcol(Sabre\HTTP\Request {}, Sabre\HTTP\Response {})

/var/www/html/3rdparty/sabre/dav/lib/DAV/Server.php - line 472:

Sabre\DAV\Server->emit("method:MKCOL", [ Sabre\HTTP ... }])

/var/www/html/3rdparty/sabre/dav/lib/DAV/Server.php - line 253:

Sabre\DAV\Server->invokeMethod(Sabre\HTTP\Request {}, Sabre\HTTP\Response {})

/var/www/html/3rdparty/sabre/dav/lib/DAV/Server.php - line 321:

Sabre\DAV\Server->start()

/var/www/html/apps/dav/lib/Server.php - line 339:

Sabre\DAV\Server->exec()

/var/www/html/apps/dav/appinfo/v2/remote.php - line 35:

OCA\DAV\Server->exec()

/var/www/html/remote.php - line 166:

require_once("/var/www/html/lib/private/Log/ErrorHandler.php"

I for the last week I have seen that a complete scans of my files in my external mounts (via sftp) sometimes lead to directories being empty. When checking the logs, I see this exact error a few times. I don’t know if it’s related.

Anyone has an idea what could be happening?

I have the same issue with my “local” binds in docker going on for weeks as well.
Shares come up and goes down.
Each time everything is working another update comes that is declared as required and then again you spend weeks to get things fixed that used to work well before. All of this it’s still very BETA after all these years.

I was able to solve my problem - the reason was a small error in the pathname. The pitfalls were the spaces: I thought I had to use quotes or escapes but the path can be entered as is.

I am encountering the same error. I also checked the SFTP connection with a different client and it is working perfectly. Only Nextcloud fails to connect even though it reports the credentials as working. Additionally, the behaviour of the personal setting for “External storage” is strange: First, there is no mark at all, then on clicking the check mark that seems to apply the setting, a red icon with exclamation point appears. Clicking on that icon immediately changes it to a green check mark. The connection still doesn’t work, and exactly the same message appears in the log as posted above.

Well sadly that can’t be the problem for me. I don’t have any spaces in path names and I tested it when jailing the ftp user to the home dir and not entering any special path which also dosn’t seem to help.