n8n-io / n8n

Free and source-available fair-code licensed workflow automation tool. Easily automate tasks across different services.
https://n8n.io
Other
48.8k stars 7.73k forks source link

Nextcloud Folder List - Incorrect path #8802

Open opcod3 opened 8 months ago

opcod3 commented 8 months ago

Bug Description

When using the nextcloud 'List Folders' integration the path for the returned items is incorrect.

The issue occurs when nextcloud is hosted at the root of a domain (the recommended configuration), instead of at domain.com/nextcloud

The issue likely occurs because of this statement: https://github.com/n8n-io/n8n/blob/11a5331e038fc383e454230dd9996015d7ce9b16/packages/nodes-base/nodes/NextCloud/NextCloud.node.ts#L1255

This works fine if nextcloud is hosted at [domain]/nextcloud but breaks it it's hosted at [domain].

Ideally the user should also be stripped from the returned path if it's present in the WebDAV url, this would allow piping the path directly into a delete file/folder node without having to manually strip the user first.

To Reproduce

  1. Setup nextcloud credentials pointing to a nextcloud instance which is hosted on the root path of a domain
  2. Set WebDAV path to https://[redacted-domain]/remote.php/dav/files/MyUser
  3. Use the nextcloud node to get a list of directories at any path e.g. /
  4. The paths of the resulting files and directories will all be prefixed with es/MyUser

Expected behavior

If:

If (Assumed behavior but not actually tested):

Operating System

Docker

n8n Version

1.29.1

Node.js Version

irrelevant

Database

PostgreSQL

Execution mode

main (default)

Joffcom commented 8 months ago

Hey @opcod3,

Thanks for the report, I have created NODE-1215 as the dev ticket to get this fixed.

datdamnzotz commented 8 months ago

n8n v1.31.2 has the same issue. my usernames are url encoded so they look like

https://example.com/cloud/remote.php/dav/files/test%40example.com/
Joffcom commented 2 weeks ago

We expect the Webdav URL to be:

https://nextcloud.tld/remote.php/webdav

When configured like this if you list a folder like /Documents you get the output in the image below which looks to be correct to me.

CleanShot 2024-10-29 at 18 37 13@2x

In my example my URL is https://nc.home.mydomain.com/remote.php/webdav

What happens if you try the URL that is like the example we provide in the credential instead of adding to that path?

datdamnzotz commented 2 weeks ago

Still doesn't work.

Nextcloud 26.0.13 n8n 1.64.3

I guess the documentation is wrong here: https://docs.n8n.io/integrations/builtin/credentials/nextcloud/

It says https://nextcloud.tld/remote.php/dav (which fails to even login on creating the credentials)

Configuring it for https://nextcloud.tld/remote.php/webdav it authenticates now. (It didn't do that before)

And it is able to retrieve directories. But they don't look like yours...

I can can get this directory list of the root (but it doesn't look like yours) image

Adding in /ebdav/Backups/

image

or /Backups gives image