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

client.exists() returns True even if resource does not exists #55

Open
Zigur opened this issue Sep 13, 2021 · 4 comments
Open

client.exists() returns True even if resource does not exists #55

Zigur opened this issue Sep 13, 2021 · 4 comments

Comments

@Zigur
Copy link

Zigur commented Sep 13, 2021

Hi, I'm using your library to write some tests around a WebDav server. Thanks for making it open source. I am new to WebDav so if I am mistaken in understanding what's going on please let me know.

If I call client.exists() on a resource that does not exist inside an existing collection I always get True back.
This seems to be due to the fact that .propfind() always returns a result even if targeting a non-existing resource (in that case you can tell the resource does not exist because all the properties in result.responses["resource-name"].properties are None).

@skshetry
Copy link
Owner

If the resource does not exist, the server should be returning 404 status, which is being checked here:

if http_resp.status_code == HTTPStatus.NOT_FOUND:
raise ResourceNotFound(path)

207 response means it exists.

Could you please share the details about the server that you are using? We use a test WebDAV server which you can play with, or else use a real servers like Nextcloud/ownCloud/Apache. Please check the Contributing Guide.

@Zigur
Copy link
Author

Zigur commented Sep 16, 2021

I am using this docker image: https://hub.docker.com/r/ionelmc/webdav/.

I am using as a test environment a (local) Kubernetes deployment with two containers, one of the being the one running the webdav docker image above.
I have noticed another strange behaviour when I try to create a new collection using client.mkdir("some_collection") or client.mkdir("/some_collection") I get a 409 and an error message saying that the parent of the collection does not exist even though the parent (I assume it to be "/") should exists (and actually client.ls("/") returns meaningful results)

@skshetry
Copy link
Owner

@Zigur, thanks I am able to reproduce. This issue happens because webdav4 does not add a trailing slash (it strips if the user passes a explicit trailing slash as well).

This is an issue with webdav4 that I'd like to fix at some point in time (see #3), but for now, I'll just patch mkdir to send a trailing slash query. :)

@skshetry
Copy link
Owner

skshetry commented Sep 17, 2021

@Zigur, I fixed the mkdir issue and released 0.9.2. I am also able to reproduce the exists returning True on not-existing resources.

I'd argue that this is a bug on the WebDAV server that you are using, as all the HTTP stuff still applies to the WebDAV.
So, like the HTTP servers, WebDAV servers should return 404 if the resource does not exist. Webdav spec is not very clear in this though.

I created #59 that supports Nginx dav extension, but this might affect other sane WebDAV servers, so I will probably not be releasing soon without further testing. You can try it out by using:

pip install git+https://github.com/skshetry/webdav4.git@nginx-compat#egg=webdav4[fsspec]

Let me know if you get any issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants