Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: File Ownership Transfer through Web UI fails with TypeError: OC\Files\Node\HookConnector::getNodeForPath(): Argument #1 ($path) must be of type string, null given #38889

Closed
6 of 8 tasks
kizzo89 opened this issue Jun 19, 2023 · 9 comments · Fixed by #39481
Assignees
Labels
1. to develop Accepted and waiting to be taken care of 26-feedback 27-feedback bug

Comments

@kizzo89
Copy link

kizzo89 commented Jun 19, 2023

⚠️ This issue respects the following points: ⚠️

Bug description

Transferring ownership of files fails with an error code. While notifications as described in the documentation are received, and the receiving folder is created, the final file transfer seems to fail. The files remain in their original location on my account.

Maybe I'm missing something or I misconfigured something?

Steps to reproduce

  1. Upload a file requested by other user. (Test file used was around 60 kB.)
  2. Go to Personal Settings -> Sharing.
  3. Click Choose file or folder to transfer. Select file.
  4. Select other user in New Owner box. Click button Transfer to .
  5. UI popup shows Ownership transfer request sent.
  6. UI notification for second user appears. Select Accept. (I tried this out with two user accounts under my control. Also, I understand transfer can take up to an hour as indicated.)
  7. Receive email from cron with the logged error as indicated in Nextcloud Logs section below.

Note that the user's receiving folder titled transferred from on was created.

Expected behavior

After second user clicks Accept, second user should receive a copy of the files in the indicated folder. Also, I expected that the files would disappear from my account.

Installation method

Community Manual installation with Archive

Nextcloud Server version

26

Operating system

Debian/Ubuntu

PHP engine version

PHP 8.1

Web server

Nginx

Database engine version

MariaDB

Is this bug present after an update or on a fresh install?

Updated from a MINOR version (ex. 22.1 to 22.2)

Are you using the Nextcloud Server Encryption module?

Encryption is Disabled

What user-backends are you using?

  • Default user-backend (database)
  • LDAP/ Active Directory
  • SSO - SAML
  • Other

Configuration report

{
    "system": {
        "instanceid": "***REMOVED SENSITIVE VALUE***",
        "passwordsalt": "***REMOVED SENSITIVE VALUE***",
        "secret": "***REMOVED SENSITIVE VALUE***",
        "trusted_domains": [
            "192.168.130.10",
            "home.abertax.com"
        ],
        "overwrite.cli.url": "https:\/\/192.168.130.10",
        "version": "26.0.2.1",
        "installed": true,
        "datadirectory": "***REMOVED SENSITIVE VALUE***",
        "maintenance": false,
        "theme": "",
        "default_phone_region": "mt",
        "defaultapp": "calendar",
        "allow_local_remote_servers": "1",
        "lost_password_link": "disabled",
        "enabledPreviewProviders": [
            "OC\\Preview\\PNG",
            "OC\\Preview\\JPEG",
            "OC\\Preview\\GIF",
            "OC\\Preview\\BMP"
        ],
        "dbname": "***REMOVED SENSITIVE VALUE***",
        "dbtype": "mysql",
        "dbhost": "***REMOVED SENSITIVE VALUE***",
        "dbport": "",
        "dbtableprefix": "oc_",
        "dbuser": "***REMOVED SENSITIVE VALUE***",
        "dbpassword": "***REMOVED SENSITIVE VALUE***",
        "mysql.utf8mb4": true,
        "ldapProviderFactory": "OCA\\User_LDAP\\LDAPProviderFactory",
        "memcache.local": "\\OC\\Memcache\\APCu",
        "memcache.distributed": "\\OC\\Memcache\\Redis",
        "memcache.locking": "\\OC\\Memcache\\Redis",
        "redis": {
            "host": "***REMOVED SENSITIVE VALUE***",
            "port": 0
        },
        "mail_from_address": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpmode": "smtp",
        "mail_sendmailmode": "smtp",
        "mail_domain": "***REMOVED SENSITIVE VALUE***",
        "mail_smtphost": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpport": "25",
        "loglevel": 1,
        "logfile": "\/var\/log\/nextcloud\/nextcloud.log",
        "app_install_overwrite": [
            "impersonate"
        ]
    }
}

List of activated Apps

nabled:
  - activity: 2.18.0
  - admin_audit: 1.16.0
  - appointments: 1.15.1
  - bruteforcesettings: 2.6.0
  - calendar: 4.4.2
  - cloud_federation_api: 1.9.0
  - comments: 1.16.0
  - contacts: 5.3.1
  - contactsinteraction: 1.7.0
  - dashboard: 7.6.0
  - dav: 1.25.0
  - federatedfilesharing: 1.16.0
  - federation: 1.16.0
  - files: 1.21.1
  - files_external: 1.18.0
  - files_pdfviewer: 2.7.0
  - files_rightclick: 1.5.0
  - files_sharing: 1.18.0
  - files_trashbin: 1.16.0
  - files_versions: 1.19.1
  - firstrunwizard: 2.15.0
  - forms: 3.3.0
  - groupfolders: 14.0.2
  - holiday_calendars: 0.3.0
  - impersonate: 1.13.1
  - integration_openproject: 2.3.7
  - logreader: 2.11.0
  - lookup_server_connector: 1.14.0
  - mail: 3.2.1
  - nextcloud_announcements: 1.15.0
  - notifications: 2.14.0
  - oauth2: 1.14.0
  - password_policy: 1.16.0
  - photos: 2.2.0
  - privacy: 1.10.0
  - provisioning_api: 1.16.0
  - recommendations: 1.5.0
  - related_resources: 1.1.0-alpha1
  - serverinfo: 1.16.0
  - settings: 1.8.0
  - sharebymail: 1.16.0
  - support: 1.9.0
  - survey_client: 1.14.0
  - suspicious_login: 4.4.0
  - systemtags: 1.16.0
  - tasks: 0.15.0
  - text: 3.7.2
  - theming: 2.1.1
  - twofactor_backupcodes: 1.15.0
  - updatenotification: 1.16.0
  - user_ldap: 1.16.0
  - user_status: 1.6.0
  - viewer: 1.10.0
  - weather_status: 1.6.0
  - workflowengine: 2.8.0
Disabled:
  - announcementcenter: 6.6.1 (installed 6.6.1)
  - circles: 26.0.0 (installed 23.0.0)
  - encryption: 2.14.0
  - keeweb: 0.6.12 (installed 0.6.12)
  - passwords: 2023.4.30 (installed 2023.4.30)
  - passwords_handbook: 2023.4.20 (installed 2023.4.20)
  - twofactor_totp: 8.0.0

Nextcloud Signing status

No errors have been found.

Nextcloud Logs

[cron] Error: TypeError: OC\Files\Node\HookConnector::getNodeForPath(): Argument #1 ($path) must be of type string, null given, called in /var/www/nextcloud/lib/private/Files/Node/HookConnector.php on line 182 at <<closure>>

0. /var/www/nextcloud/lib/private/Files/Node/HookConnector.php line 182
   OC\Files\Node\HookConnector->getNodeForPath()
1. /var/www/nextcloud/lib/private/legacy/OC_Hook.php line 105
   OC\Files\Node\HookConnector->rename()
2. /var/www/nextcloud/lib/private/Files/View.php line 789
   OC_Hook::emit()
3. /var/www/nextcloud/apps/files/lib/Service/OwnershipTransferService.php line 378
   OC\Files\View->rename()
4. /var/www/nextcloud/apps/files/lib/Service/OwnershipTransferService.php line 179
   OCA\Files\Service\OwnershipTransferService->transferFiles()
5. /var/www/nextcloud/apps/files/lib/BackgroundJob/TransferOwnership.php line 115
   OCA\Files\Service\OwnershipTransferService->transfer()
6. /var/www/nextcloud/lib/public/BackgroundJob/Job.php line 78
   OCA\Files\BackgroundJob\TransferOwnership->run()
7. /var/www/nextcloud/lib/public/BackgroundJob/QueuedJob.php line 57
   OCP\BackgroundJob\Job->start()
8. /var/www/nextcloud/lib/public/BackgroundJob/QueuedJob.php line 47
   OCP\BackgroundJob\QueuedJob->start()
9. /var/www/nextcloud/cron.php line 152
   OCP\BackgroundJob\QueuedJob->execute()

at 2023-06-19T09:30:02+00:00

Additional info

No response

@kizzo89 kizzo89 added 0. Needs triage Pending check for reproducibility or if it fits our roadmap bug labels Jun 19, 2023
@solracsf solracsf changed the title [Bug]: File Ownership Transfer through Web UI fails with Error. [Bug]: File Ownership Transfer through Web UI fails with TypeError: OC\Files\Node\HookConnector::getNodeForPath(): Argument #1 ($path) must be of type string, null given Jun 19, 2023
@solracsf
Copy link
Member

solracsf commented Jun 20, 2023

Please find the entry for HookConnector::getNodeForPath in your data/nextcloud.log to get the full entry and its trace (JSON formated).

@kizzo89
Copy link
Author

kizzo89 commented Jun 20, 2023

Here's the relevant entry from the logfile:

{
  "reqId": "jpkhTf97waH0X8jTHTQg",
  "level": 3,
  "time": "2023-06-19T09:00:02+00:00",
  "remoteAddr": "",
  "user": "--",
  "app": "cron",
  "method": "",
  "url": "--",
  "message": "OC\\Files\\Node\\HookConnector::getNodeForPath(): Argument #1 ($path) must be of type string, null given, called in /var/www/nextcloud/lib/private/Files/Node/HookConnector.php on line 182",
  "userAgent": "--",
  "version": "26.0.2.1",
  "exception": {
    "Exception": "TypeError",
    "Message": "OC\\Files\\Node\\HookConnector::getNodeForPath(): Argument #1 ($path) must be of type string, null given, called in /var/www/nextcloud/lib/private/Files/Node/HookConnector.php on line 182",
    "Code": 0,
    "Trace": [
      {
        "file": "/var/www/nextcloud/lib/private/Files/Node/HookConnector.php",
        "line": 182,
        "function": "getNodeForPath",
        "class": "OC\\Files\\Node\\HookConnector",
        "type": "->"
      },
      {
        "file": "/var/www/nextcloud/lib/private/legacy/OC_Hook.php",
        "line": 105,
        "function": "rename",
        "class": "OC\\Files\\Node\\HookConnector",
        "type": "->"
      },
      {
        "file": "/var/www/nextcloud/lib/private/Files/View.php",
        "line": 789,
        "function": "emit",
        "class": "OC_Hook",
        "type": "::"
      },
      {
        "file": "/var/www/nextcloud/apps/files/lib/Service/OwnershipTransferService.php",
        "line": 378,
        "function": "rename",
        "class": "OC\\Files\\View",
        "type": "->"
      },
      {
        "file": "/var/www/nextcloud/apps/files/lib/Service/OwnershipTransferService.php",
        "line": 179,
        "function": "transferFiles",
        "class": "OCA\\Files\\Service\\OwnershipTransferService",
        "type": "->"
      },
      {
        "file": "/var/www/nextcloud/apps/files/lib/BackgroundJob/TransferOwnership.php",
        "line": 115,
        "function": "transfer",
        "class": "OCA\\Files\\Service\\OwnershipTransferService",
        "type": "->"
      },
      {
        "file": "/var/www/nextcloud/lib/public/BackgroundJob/Job.php",
        "line": 78,
        "function": "run",
        "class": "OCA\\Files\\BackgroundJob\\TransferOwnership",
        "type": "->"
      },
      {
        "file": "/var/www/nextcloud/lib/public/BackgroundJob/QueuedJob.php",
        "line": 57,
        "function": "start",
        "class": "OCP\\BackgroundJob\\Job",
        "type": "->"
      },
      {
        "file": "/var/www/nextcloud/lib/public/BackgroundJob/QueuedJob.php",
        "line": 47,
        "function": "start",
        "class": "OCP\\BackgroundJob\\QueuedJob",
        "type": "->"
      },
      {
        "file": "/var/www/nextcloud/cron.php",
        "line": 152,
        "function": "execute",
        "class": "OCP\\BackgroundJob\\QueuedJob",
        "type": "->"
      }
    ],
    "File": "/var/www/nextcloud/lib/private/Files/Node/HookConnector.php",
    "Line": 229,
    "CustomMessage": "--"
  }
}

FYI, background jobs are running under cron. Let me know if you need more info. Thanks.

@miaulalala miaulalala added 1. to develop Accepted and waiting to be taken care of and removed 0. Needs triage Pending check for reproducibility or if it fits our roadmap labels Jun 26, 2023
@miaulalala
Copy link
Contributor

I can reproduce with current master.

@kernstock
Copy link

We're seeing the same issue on 26.0.2.

@szaimen
Copy link
Contributor

szaimen commented Jun 28, 2023

cc @come-nc

@Volker-K
Copy link

We're seeing the same issue on 26.0.2.

Same here, migrated to 26.0.2 this morning, Error occurred 2 times until now.
Just checked: Transfer does not work "Transferred from"-folder is created but does not contain the respective files.

@miaulalala miaulalala self-assigned this Jun 29, 2023
@miaulalala
Copy link
Contributor

The problem is this line:

if (!str_starts_with($path, $root)) {

It compares the root of the file path with the views fake root, and that fails for the transferring user.

User Alice (transferring) has path /files/alice/ and user Bob (receiving) has /files/bob/ASuperLongFilePath, so the string comparison fails.

@miaulalala
Copy link
Contributor

Possibly a regression from #36774

@miaulalala
Copy link
Contributor

Using $view->copy() and $view->deleteAll() instead of $view->rename() works but it feels insecure as it could lead to data loss. It also triggers an activity email that could lead to a lot of confusion:

image

Even though "remote user" is just a placeholder for the cron user doing its thing, it still could lead people to think someone nefarious has access to the system.

@solracsf solracsf changed the title [Bug]: File Ownership Transfer through Web UI fails with TypeError: OC\Files\Node\HookConnector::getNodeForPath(): Argument #1 ($path) must be of type string, null given [Bug]: File Ownership Transfer through Web UI fails with TypeError: OC\Files\Node\HookConnector::getNodeForPath(): Argument #1 ($path) must be of type string, null given Aug 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1. to develop Accepted and waiting to be taken care of 26-feedback 27-feedback bug
Projects
6 participants