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

Getting information about a folder overwritten by a file gives 500 error instead of 404 #1239

Closed
jasson99 opened this issue Jul 21, 2020 · 9 comments
Labels
Interaction:Needs-help Asking some hints to engineering when the issue can't be reproduced Type:Bug

Comments

@jasson99
Copy link
Contributor

Description:

There are scenarios where a file(say testfile.txt) is copied over the top of an existing folder(say FOLDER), which overwrites the folder. The folder changes into the file and the name is of the folder(FOLDER). When we try to find if the actual folder(FOLDER) exists for the user, then 500 Internal server error is returned instead of 404 Not Found. However, if we check for the completely non-existence folder, which was never created, then it returns 404 correctly.

Steps To Reproduce:

  1. Create User Alice
  2. Alice creates a file testfile.txt with content some data
curl -u Alice:1234 -X PUT "http://localhost:9140/remote.php/webdav/testfile.txt" -d "some data" -v                                                  

< HTTP/1.1 201 Created

  1. Alice creates folder FOLDER
curl -u Alice:1234 -X MKCOL "http://localhost:9140/remote.php/webdav/FOLDER" -v                                                                       

< HTTP/1.1 201 Created

  1. Alice creates folder FOLDER/sample-folder
curl -u Alice:1234 -X MKCOL "http://localhost:9140/remote.php/webdav/FOLDER/sample-folder" -v                                                         

< HTTP/1.1 201 Created

  1. Alice copies file testfile.txt to FOLDER using webdav API
curl -u Alice:1234 -X COPY "http://localhost:9140/remote.php/webdav/testfile.txt" -H "Destination: http://localhost:9140/remote.php/webdav/FOLDER" -v 

< HTTP/1.1 204 No Content

  1. Alice checks the content of file FOLDER
curl -u Alice:1234 -X GET "http://localhost:9140/remote.php/webdav/FOLDER" -v                                                                      

< HTTP/1.1 200 OK

some data%                                    
  1. Alice checks if folder FOLDER/sample-folder exists
curl -u Alice:1234 -X GET "http://localhost:9140/remote.php/webdav/FOLDER/sample-folder" -v


< HTTP/1.1 500 Internal Server Error

  1. But when Alice checks for a folder Non-existent-folder which was never created
 curl -u Alice:1234 -X GET "http://localhost:9140/remote.php/webdav/Not-Existent-Folder" -v 

< HTTP/1.1 404 Not Found

@jasson99
Copy link
Contributor Author

And the ocis-sever logged the following:

2020-07-21T11:59:17+05:45 WRN core access token not set pkg=rhttp service=reva traceid=a74bdfcc3e36a2048d8e74b916a64f33
2020-07-21T11:59:17+05:45 INF unary code=OK end="21/Jul/2020:11:59:17 +0545" from=tcp://127.0.0.1:34136 pkg=rgrpc service=reva start="21/Jul/2020:11:59:17 +0545" time_ns=17363 traceid=a74bdfcc3e36a2048d8e74b916a64f33 uri=/cs3.auth.registry.v1beta1.RegistryAPI/GetAuthProvider user-agent=grpc-go/1.26.0
2020-07-21T11:59:17+05:45 INF user id:<idp:"https://localhost:9200" opaque_id:"Alice" > username:"Alice" mail:"alice@example.org" display_name:"User Alice"  authenticated pkg=rgrpc service=reva traceid=a74bdfcc3e36a2048d8e74b916a64f33
2020-07-21T11:59:17+05:45 INF unary code=OK end="21/Jul/2020:11:59:17 +0545" from=tcp://127.0.0.1:42098 pkg=rgrpc service=reva start="21/Jul/2020:11:59:17 +0545" time_ns=12046946 traceid=a74bdfcc3e36a2048d8e74b916a64f33 uri=/cs3.auth.provider.v1beta1.ProviderAPI/Authenticate user-agent=grpc-go/1.26.0
2020-07-21T11:59:17+05:45 INF unary code=OK end="21/Jul/2020:11:59:17 +0545" from=tcp://127.0.0.1:34144 pkg=rgrpc service=reva start="21/Jul/2020:11:59:17 +0545" time_ns=62913 traceid=a74bdfcc3e36a2048d8e74b916a64f33 uri=/cs3.storage.registry.v1beta1.RegistryAPI/GetStorageProvider user-agent=grpc-go/1.26.0
2020-07-21T11:59:17+05:45 INF unary code=OK end="21/Jul/2020:11:59:17 +0545" from=tcp://127.0.0.1:33386 pkg=rgrpc service=reva start="21/Jul/2020:11:59:17 +0545" time_ns=190098 traceid=a74bdfcc3e36a2048d8e74b916a64f33 uri=/cs3.storage.provider.v1beta1.ProviderAPI/CreateHome user-agent=grpc-go/1.26.0
2020-07-21T11:59:17+05:45 INF unary code=OK end="21/Jul/2020:11:59:17 +0545" from=tcp://127.0.0.1:34134 pkg=rgrpc service=reva start="21/Jul/2020:11:59:17 +0545" time_ns=13636702 traceid=a74bdfcc3e36a2048d8e74b916a64f33 uri=/cs3.gateway.v1beta1.GatewayAPI/Authenticate user-agent=grpc-go/1.26.0
2020-07-21T11:59:17+05:45 INF core access token generated pkg=rhttp service=reva traceid=a74bdfcc3e36a2048d8e74b916a64f33
2020-07-21T11:59:17+05:45 INF unary code=OK end="21/Jul/2020:11:59:17 +0545" from=tcp://127.0.0.1:34144 pkg=rgrpc service=reva start="21/Jul/2020:11:59:17 +0545" time_ns=82650 traceid=a74bdfcc3e36a2048d8e74b916a64f33 uri=/cs3.storage.registry.v1beta1.RegistryAPI/GetStorageProvider user-agent=grpc-go/1.26.0
2020-07-21T11:59:17+05:45 ERR home/jasminebaral/go/pkg/mod/github.com/cs3org/reva@v0.1.1-0.20200709064551-91eed007038f/internal/grpc/services/storageprovider/storageprovider.go:465 > error stating file: path:"/home/FOLDER/sample-folder"  error="ocfs: error stating /var/tmp/reva/data/Alice/files/FOLDER/sample-folder: stat /var/tmp/reva/data/Alice/files/FOLDER/sample-folder: not a directory" pkg=rgrpc service=reva traceid=a74bdfcc3e36a2048d8e74b916a64f33
2020-07-21T11:59:17+05:45 INF unary code=OK end="21/Jul/2020:11:59:17 +0545" from=tcp://127.0.0.1:33386 pkg=rgrpc service=reva start="21/Jul/2020:11:59:17 +0545" time_ns=418039 traceid=a74bdfcc3e36a2048d8e74b916a64f33 uri=/cs3.storage.provider.v1beta1.ProviderAPI/Stat user-agent=grpc-go/1.26.0
2020-07-21T11:59:17+05:45 INF unary code=OK end="21/Jul/2020:11:59:17 +0545" from=tcp://127.0.0.1:34134 pkg=rgrpc service=reva start="21/Jul/2020:11:59:17 +0545" time_ns=1337523 traceid=a74bdfcc3e36a2048d8e74b916a64f33 uri=/cs3.gateway.v1beta1.GatewayAPI/Stat user-agent=grpc-go/1.26.0
2020-07-21T11:59:17+05:45 WRN grpc request failed code="\x0f" pkg=rhttp service=reva traceid=a74bdfcc3e36a2048d8e74b916a64f33
2020-07-21T11:59:17+05:45 ERR http end="21/Jul/2020:11:59:17 +0545" host=127.0.0.1 method=GET pkg=rhttp proto=HTTP/1.1 service=reva size=0 start="21/Jul/2020:11:59:17 +0545" status=500 time_ns=16199921 traceid=a74bdfcc3e36a2048d8e74b916a64f33 uri=/remote.php/webdav/FOLDER/sample-folder url=/remote.php/webdav/FOLDER/sample-folder

@phil-davis
Copy link
Contributor

This might be a general problem when attempting to reference a file as if it is a folder - putting a file somewhere in a path that should be made up of folders.

For example:

curl -u Alice:1234 -X GET "http://localhost:9140/remote.php/webdav/testfile.txt/somename" -v

@jasson99 what happens when testfile.txt is just an ordinary file that has just been created, and then a webdav request is done that mentions it as if it is a folder?

Is there a "sensible" response from oC10 and a different response from OCIS?

@kiranparajuli589
Copy link
Contributor

kiranparajuli589 commented Jul 21, 2020

@phil-davis @jasson99 If we request like

curl -u Alice:1234 -X GET "http://localhost:9140/remote.php/webdav/testfile.txt/somename" -v
  • if there is testfile.txt present for user Alice, then the response is like exactly same as mentioned above on the issue description.
    i.e < HTTP/1.1 500 Internal Server Error
  • if there is no testfile.txt present for user Alice then the response is with 404: NotFound

@phil-davis
Copy link
Contributor

"good" - I guess that reva-OCIS walks down the "folder" resources in the requested path. If the resource does not exist, then easy, a 404 gets returned. If the resource is a folder, then also easy, continue walking down to the next folder in the path.

But if the resource is in the middle of the path, but exists and is a file then something falls over. Somewhere in that code it likely just needs to catch when a resource is in the middle of the path and is a file. In that case return 404.

@butonic butonic transferred this issue from owncloud/ocis-reva Jan 18, 2021
@refs refs added Interaction:Needs-help Asking some hints to engineering when the issue can't be reproduced Type:Bug labels Jan 18, 2021
@settings settings bot removed the p3-medium label Apr 7, 2021
@ScharfViktor
Copy link
Contributor

ScharfViktor commented Aug 31, 2021

Perhaps something has changed. Getting information about a folder using the GET method always gives HTTP/1.1 501 Not Implemented

server log:
21-08-31T16:41:28+02:00 WRN resource is a folder and cannot be downloaded handler=get path=/home/1/2 pkg=rhttp service=storage svc=ocdav traceid=4cfe3d3412acac1417f7e4be6986155d 2021-08-31T16:41:28+02:00 ERR http end="31/Aug/2021:16:41:28 +0200" host=::1 method=GET pkg=rhttp proto=HTTP/1.1 service=storage size=0 start="31/Aug/2021:16:41:28 +0200" status=501 time_ns=52276458 traceid=4cfe3d3412acac1417f7e4be6986155d uri=/remote.php/webdav/1/2 url=/remote.php/webdav/1/2

question: should it work correctly in this case?

method curl -X PROPFIND "http://localhost:9140/remote.php/webdav/1/1" works to get information about the folder

@SagarGi
Copy link
Member

SagarGi commented Aug 12, 2022

The above bug seems to have been fixed and the expected to failure for ocis that has been tag with this issue is irrelevant to this but acts differently than oc10 when we copy the file on the top of an existing folder. The expected to failure tagged with this issue is related to #3874 issue. I think this issue can be closed. @phil-davis @kiranparajuli589

@kiranparajuli589
Copy link
Contributor

kiranparajuli589 commented Aug 15, 2022

@SagarGi if the issue is no more relevant, please close it with the proper current behavior in a comment. The expected failure files also need an update regarding the scenarios linked with these issues.

@amrita-shrestha
Copy link
Contributor

amrita-shrestha commented Aug 8, 2023

RE-TESTED As @SagarGi mentioned this issue has been resolved but the issue exists in expected-failure file and need to remove.

TO-DO QA-TEAM

#### [Getting information about a folder overwritten by a file gives 500 error instead of 404](https://github.com/owncloud/ocis/issues/1239)

- [coreApiWebdavProperties1/copyFile.feature:272](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/coreApiWebdavProperties1/copyFile.feature#L272)
- [coreApiWebdavProperties1/copyFile.feature:273](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/coreApiWebdavProperties1/copyFile.feature#L273)
- [coreApiWebdavProperties1/copyFile.feature:290](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/coreApiWebdavProperties1/copyFile.feature#L290)
- [coreApiWebdavProperties1/copyFile.feature:291](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/coreApiWebdavProperties1/copyFile.feature#L291)

@amrita-shrestha
Copy link
Contributor

amrita-shrestha commented Aug 22, 2023

@SwikritiT

@SwikritiT SwikritiT removed their assignment Aug 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Interaction:Needs-help Asking some hints to engineering when the issue can't be reproduced Type:Bug
Projects
None yet
Development

No branches or pull requests

8 participants