Skip to content

fix: Avoid failing on fopen for NonExistingFiles#4829

Merged
juliusknorr merged 1 commit into
mainfrom
fix/secure-view-new-file
Jun 5, 2025
Merged

fix: Avoid failing on fopen for NonExistingFiles#4829
juliusknorr merged 1 commit into
mainfrom
fix/secure-view-new-file

Conversation

@juliusknorr
Copy link
Copy Markdown
Member

@juliusknorr juliusknorr commented Jun 5, 2025

An easy way to trigger this is to enable watermarking but no condition and then create a new file from a template.

This only happens when calling the node API with newFile and some content. A way to reproduce this locally is to create a new markdown file from a template in the template directory.

Based on this exception trace that was catched:

{
 "reqId": "XXXXX",
 "level": 3,
 "user": "--",
 "app": "no app in context",
 "method": "POST",
 "url": "/ocs/v2.php/apps/spreed/api/v1/recording/1234567/store",
 "message": "/admin/files/Talk/Recording/1234567/Recording XXXXXX.webm",
 "userAgent": "Nextcloud-Talk-Recording/0.1",
 "version": "31.0.5.1",
 "exception": {
   "Exception": "OCP\\Files\\NotFoundException",
   "Message": "/admin/files/Talk/Recording/1234567/Recording XXXXXX.webm",
   "Code": 0,
   "Trace": [
     {
       "file": "/var/www/nextcloud/lib/private/Files/Node/Folder.php",
       "line": 107,
       "function": "get",
       "class": "OC\\Files\\Node\\Root",
       "type": "->",
       "args": [
         "/admin/files/Talk/Recording/1234567/Recording XXXXXX.webm"
       ]
     },
     {
       "file": "/var/www/nextcloud/custom_apps/richdocuments/lib/Storage/SecureViewWrapper.php",
       "line": 96,
       "function": "get",
       "class": "OC\\Files\\Node\\Folder",
       "type": "->",
       "args": [
         "files/Talk/Recording/1234567/Recording XXXXXX.webm"
       ]
     },
     {
       "file": "/var/www/nextcloud/custom_apps/richdocuments/lib/Storage/SecureViewWrapper.php",
       "line": 81,
       "function": "shouldSecure",
       "class": "OCA\\Richdocuments\\Storage\\SecureViewWrapper",
       "type": "->",
       "args": [
         "files/Talk/Recording/1234567/Recording XXXXXX.webm"
       ]
     },
     {
       "file": "/var/www/nextcloud/custom_apps/richdocuments/lib/Storage/SecureViewWrapper.php",
       "line": 42,
       "function": "checkFileAccess",
       "class": "OCA\\Richdocuments\\Storage\\SecureViewWrapper",
       "type": "->",
       "args": [
         "files/Talk/Recording/1234567/Recording XXXXXX.webm"
       ]
     },
     {
       "file": "/var/www/nextcloud/lib/private/Files/View.php",
       "line": 629,
       "function": "fopen",
       "class": "OCA\\Richdocuments\\Storage\\SecureViewWrapper",
       "type": "->",
       "args": [
         "files/Talk/Recording/1234567/Recording XXXXXX.webm",
         "w"
       ]
     },
     {
       "file": "/var/www/nextcloud/lib/private/Files/Node/Folder.php",
       "line": 156,
       "function": "file_put_contents",
       "class": "OC\\Files\\View",
       "type": "->",
       "args": [
         "/admin/files/Talk/Recording/1234567/Recording XXXXXX.webm",
         null
       ]
     },
     {
       "file": "/var/www/nextcloud/custom_apps/spreed/lib/Service/RecordingService.php",
       "line": 142,
       "function": "newFile",
       "class": "OC\\Files\\Node\\Folder",
       "type": "->",
       "args": [
         "Recording XXXXXX.webm",
         null
       ]
     },
     {
       "file": "/var/www/nextcloud/custom_apps/spreed/lib/Controller/RecordingController.php",
       "line": 409,
       "function": "store",
       "class": "OCA\\Talk\\Service\\RecordingService",
       "type": "->",
       "args": [
         {
           "__class__": "OCA\\Talk\\Room"
         },
         "admin",
         {
           "name": "Recording XXXXXX.webm",
           "full_path": "Recording XXXXXX.webm",
           "type": "",
           "tmp_name": "/upload_tmp/phpB8VqhN",
           "error": 0,
           "0": "And 1 more entries, set log level to debug to see all entries"
         }
       ]
     },
     {
       "file": "/var/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php",
       "line": 200,
       "function": "store",
       "class": "OCA\\Talk\\Controller\\RecordingController",
       "type": "->",
       "args": [
         "admin"
       ]
     },
     {
       "file": "/var/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php",
       "line": 114,
       "function": "executeController",
       "class": "OC\\AppFramework\\Http\\Dispatcher",
       "type": "->",
       "args": [
         {
           "__class__": "OCA\\Talk\\Controller\\RecordingController"
         },
         "store"
       ]
     },
     {
       "file": "/var/www/nextcloud/lib/private/AppFramework/App.php",
       "line": 161,
       "function": "dispatch",
       "class": "OC\\AppFramework\\Http\\Dispatcher",
       "type": "->",
       "args": [
         {
           "__class__": "OCA\\Talk\\Controller\\RecordingController"
         },
         "store"
       ]
     },
     {
       "file": "/var/www/nextcloud/lib/private/Route/Router.php",
       "line": 307,
       "function": "main",
       "class": "OC\\AppFramework\\App",
       "type": "::",
       "args": [
         "OCA\\Talk\\Controller\\RecordingController",
         "store",
         {
           "__class__": "OC\\AppFramework\\DependencyInjection\\DIContainer"
         },
         {
           "apiVersion": "v1",
           "token": "1234567",
           "_route": "ocs.spreed.recording.store"
         }
       ]
     },
     {
       "file": "/var/www/nextcloud/ocs/v1.php",
       "line": 49,
       "function": "match",
       "class": "OC\\Route\\Router",
       "type": "->",
       "args": [
         "/ocsapp/apps/spreed/api/v1/recording/1234567/store"
       ]
     },
     {
       "file": "/var/www/nextcloud/ocs/v2.php",
       "line": 7,
       "args": [
         "/var/www/nextcloud/ocs/v1.php"
       ],
       "function": "require_once"
     }
   ],
   "File": "/var/www/nextcloud/lib/private/Files/Node/Root.php",
   "Line": 182,
   "message": "/admin/files/Talk/Recording/1234567/Recording XXXXXX.webm",
   "exception": {},
   "CustomMessage": "/admin/files/Talk/Recording/1234567/Recording XXXXXX.webm"
 }
}

Signed-off-by: Julius Knorr <jus@bitgrid.net>
@juliusknorr juliusknorr requested a review from elzody as a code owner June 5, 2025 13:25
@juliusknorr juliusknorr added bug Something isn't working 3. to review Ready to be reviewed labels Jun 5, 2025
@juliusknorr
Copy link
Copy Markdown
Member Author

/backport to stable31

@juliusknorr juliusknorr merged commit 35a916e into main Jun 5, 2025
68 checks passed
@juliusknorr juliusknorr deleted the fix/secure-view-new-file branch June 5, 2025 13:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3. to review Ready to be reviewed bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants