owncloud / ocis

:atom_symbol: ownCloud Infinite Scale Stack
https://doc.owncloud.com/ocis/next/
Apache License 2.0
1.36k stars 180 forks source link

[wopi] Check file info return 500 if file has been deleted #10097

Open amrita-shrestha opened 2 days ago

amrita-shrestha commented 2 days ago

Describe the bug

try to get file info using wopi, which returns 500 if a file has been deleted

Steps to reproduce

  1. get access token and URL using endpoint /app/open?app_name=$app&file_id=$fileId returns
    "app_url":"https://host.docker.internal:9980/browser/d5ebff5/cool.html?WOPISrc=https%3A%2F%2Fhost.docker.internal%3A9300%2Fwopi%2Ffiles%2Ffccd2d62499f7173360",
    "method":"POST",
    "form_parameters":{"access_token":"eyJhbGciOiJIUzI1NiIjl0BboY4ktwyLYivcSK08",
    "access_token_ttl":"1726739024000"
    }
  2. delete file from the ocis server
  3. using WOPISrc and access_token from the above response send get request return 500 status code

Expected behavior

401 unauthorized or 404 code should be return

Actual behavior

500 status code returned

Setup

Please describe how you started the server and provide a list of relevant environment variables or configuration files.

```console ownCloud Infinite Scale Edition Community Version 6.3.0+283948487 Web client version 10.2.0 ```

Additional context

Add any other context about the problem here.

jvillafanez commented 2 days ago

For reference, log entry below:

{"level":"error","service":"collaboration","request-id":"","proto":"HTTP/1.1","method":"GET","path":"/wopi/files/3087b86e78853869ae2ec56a7cc646cbf8b8d9e058ed123dcf19ced87e57cd86","WopiSessionId":"","WopiOverride":"","WopiProof":"","WopiProofOld":"","WopiStamp":"","FileReference":"resource_id:{storage_id:\"7edebe16-6335-47a0-bf76-3885202dffcf\"  opaque_id:\"22f17a98-4255-4c1b-856f-f64b5a36917e\"  space_id:\"542053c5-dafc-45c8-92e2-6bb01a8bec29\"}  path:\".\"","ViewMode":"VIEW_MODE_READ_WRITE","Requester":"idp:\"https://ocis.jp.solidgear.prv\"  opaque_id:\"542053c5-dafc-45c8-92e2-6bb01a8bec29\"  type:USER_TYPE_PRIMARY","StatusCode":"CODE_NOT_FOUND","StatusMsg":"stat: error: not found: ","time":"2024-09-18T16:04:50Z","line":"/home/juan/src/ocis/ocis/services/collaboration/pkg/connector/fileconnector.go:1060","message":"CheckFileInfo: stat failed with unexpected status"}

We can detect that case and return an appropriate 404 error