nextcloud / server

☁️ Nextcloud server, a safe home for all your data
https://nextcloud.com
GNU Affero General Public License v3.0
26.79k stars 4k forks source link

CacheQueryBuilder::whereFileId() must be of the type int, null given #19009

Closed solracsf closed 3 years ago

solracsf commented 4 years ago

Reproduce case here: https://github.com/nextcloud/server/issues/19009#issuecomment-621916168

[remote] Error: TypeError: Argument 1 passed to OC\Files\Cache\CacheQueryBuilder::whereFileId() must be of the type int, null given, called in /srv/lib/private/Files/Cache/Cache.php on line 655 at <<closure>>

 0. /srv/lib/private/Files/Cache/Cache.php line 655
    OC\Files\Cache\CacheQueryBuilder->whereFileId(null)
 1. /srv/lib/private/Files/Cache/Cache.php line 579
    OC\Files\Cache\Cache->moveFromCache(OC\Files\Cache\Cache {}, "files/TEST A/DSC_0073.jpg.part", "files/TEST A/DSC_0073.jpg")
 2. /srv/lib/private/Files/ObjectStore/ObjectStoreStorage.php line 481
    OC\Files\Cache\Cache->move("files/TEST A/DSC_0073.jpg.part", "files/TEST A/DSC_0073.jpg")
 3. /srv/lib/private/Files/Storage/Wrapper/Wrapper.php line 630
    OC\Files\ObjectStore\ObjectStoreStorage->writeStream("files/TEST A/DSC_0073.jpg", null, 10987936)
 4. /srv/lib/private/Files/Storage/Wrapper/Wrapper.php line 630
    OC\Files\Storage\Wrapper\Wrapper->writeStream("files/TEST A/DSC_0073.jpg", null, null)
 5. /srv/apps/dav/lib/Connector/Sabre/File.php line 192
    OC\Files\Storage\Wrapper\Wrapper->writeStream("files/TEST A/DSC_0073.jpg", null)
 6. /srv/apps/dav/lib/Connector/Sabre/Directory.php line 156
    OCA\DAV\Connector\Sabre\File->put(null)
 7. /srv/3rdparty/sabre/dav/lib/DAV/Tree.php line 316
    OCA\DAV\Connector\Sabre\Directory->createFile("DSC_0073.jpg", null)
 8. /srv/3rdparty/sabre/dav/lib/DAV/Tree.php line 130
    Sabre\DAV\Tree->copyNode(OCA\DAV\Upload\FutureFile {}, OCA\DAV\Connector\Sabre\Directory {}, "DSC_0073.jpg")
 9. /srv/3rdparty/sabre/dav/lib/DAV/Tree.php line 161
    Sabre\DAV\Tree->copy("uploads/u221219 ... e", "files/u221219/TEST A/DSC_0073.jpg")
10. /srv/3rdparty/sabre/dav/lib/DAV/CorePlugin.php line 642
    Sabre\DAV\Tree->move("uploads/u221219 ... e", "files/u221219/TEST A/DSC_0073.jpg")
11. <<closure>>
    Sabre\DAV\CorePlugin->httpMove(Sabre\HTTP\Reque ... "}, Sabre\HTTP\Response {})
12. /srv/3rdparty/sabre/event/lib/EventEmitterTrait.php line 105
    call_user_func_array([Sabre\DAV\CorePlugin {},"httpMove"], [Sabre\HTTP\Requ ... }])
13. /srv/3rdparty/sabre/dav/lib/DAV/Server.php line 479
    Sabre\Event\EventEmitter->emit("method:MOVE", [Sabre\HTTP\Requ ... }])
14. /srv/3rdparty/sabre/dav/lib/DAV/Server.php line 254
    Sabre\DAV\Server->invokeMethod(Sabre\HTTP\Reque ... "}, Sabre\HTTP\Response {})
15. /srv/apps/dav/lib/Server.php line 319
    Sabre\DAV\Server->exec()
16. /srv/apps/dav/appinfo/v2/remote.php line 35
    OCA\DAV\Server->exec()
17. /srv/remote.php line 165
    require_once("/mnt/ ... p")

MOVE /remote.php/dav/uploads/u221219/web-file-upload-360dc11ec3f6b727dccf1f21382d298b-1579507080603/.file
gnikyt commented 4 years ago

Same issue here. Object Storage via S3.

JUVOJustin commented 4 years ago

Same Error with a nearly identical setup

kesselb commented 4 years ago

MOVE /remote.php/dav/uploads/u221219/web-file-upload-360dc11ec3f6b727dccf1f21382d298b-1579507080603/.file is related to assembly a file uploaded in chunks. I don't know how to reproduce that kind of failure. Uploading files in chunks with s3 (minio) works with my development setup.

https://github.com/nextcloud/server/blob/d9184584e08def794a298966afde24f232b7abf5/lib/private/Files/Cache/Cache.php#L614

$sourceData could be false. Probably a check is missing here. But the actual error is happening earlier.

 6. /srv/apps/dav/lib/Connector/Sabre/Directory.php line 156
    OCA\DAV\Connector\Sabre\File->put(null)
 7. /srv/3rdparty/sabre/dav/lib/DAV/Tree.php line 316
    OCA\DAV\Connector\Sabre\Directory->createFile("DSC_0073.jpg", null)
 8. /srv/3rdparty/sabre/dav/lib/DAV/Tree.php line 130
    Sabre\DAV\Tree->copyNode(OCA\DAV\Upload\FutureFile {}, OCA\DAV\Connector\Sabre\Directory {}, "DSC_0073.jpg")

It seems that $data is null.

https://github.com/nextcloud/3rdparty/blob/b0afba6d6508a1c85332cf8c61e90ad91b289ebc/sabre/dav/lib/DAV/Tree.php#L302-L311

$data = $source->get(); returns null.

cc @rullzer @icewind1991

solracsf commented 4 years ago

For the record, i'm able to reproduce it every time with this test case:

image

1 file uploaded, 4 errors

image

And in the logfile 4 lines like:

Error: TypeError: Argument 1 passed to OC\Files\Cache\CacheQueryBuilder::whereFileId() must be of the type int, null given, called in /srv/lib/private/Files/Cache/Cache.php on line 655

williamsmt commented 4 years ago

I can consistently repro this issue, but with a different test case. Same specs as @acsfer

  1. Open NC to establish session
  2. Place NC in maintenance mode
  3. Refresh session from step 1 and confirm MM screen
  4. Take NC out of MM
  5. Refresh session and navigate to any app ('Deck' is used here, but 'Files' and 'Photos' app also repro'd)
[index] Error: TypeError: Argument 1 passed to OC\Files\Cache\CacheQueryBuilder::whereFileId() must be of the type integer, null given, called in /var/www/nextcloud/lib/private/Files/Cache/Cache.php on line 655 at <<closure>>

 0. /var/www/nextcloud/lib/private/Files/Cache/Cache.php line 655
    OC\Files\Cache\CacheQueryBuilder->whereFileId(null)
 1. /var/www/nextcloud/lib/private/Files/Cache/Cache.php line 579
    OC\Files\Cache\Cache->moveFromCache(OC\Files\Cache\Cache {}, "appdata_ochey15 ... t", "appdata_ochey15 ... s")
 2. /var/www/nextcloud/lib/private/Files/ObjectStore/ObjectStoreStorage.php line 476
    OC\Files\Cache\Cache->move("appdata_ochey15 ... t", "appdata_ochey15 ... s")
 3. /var/www/nextcloud/lib/private/Files/ObjectStore/ObjectStoreStorage.php line 400
    OC\Files\ObjectStore\ObjectStoreStorage->writeStream("appdata_ochey15 ... s", null, 1)
 4. /var/www/nextcloud/lib/private/Files/ObjectStore/ObjectStoreStorage.php line 313
    OC\Files\ObjectStore\ObjectStoreStorage->writeBack("/tmp/oc_tmp_mwn3YU-.css", "appdata_ochey15 ... s")
 5. <<closure>>
    OC\Files\ObjectStore\ObjectStoreStorage->OC\Files\ObjectStore\{closure}("*** sensitive parameters replaced ***")
 6. /var/www/nextcloud/3rdparty/icewind/streams/src/CallbackWrapper.php line 121
    call_user_func(Closure {})
 7. <<closure>>
    Icewind\Streams\CallbackWrapper->stream_close()
 8. /var/www/nextcloud/lib/private/Files/ObjectStore/ObjectStoreStorage.php line 421
    fclose(null)
 9. /var/www/nextcloud/lib/private/Files/ObjectStore/ObjectStoreStorage.php line 376
    OC\Files\ObjectStore\ObjectStoreStorage->file_put_contents("appdata_ochey15 ... s", " ")
10. /var/www/nextcloud/lib/private/Files/Storage/Wrapper/Wrapper.php line 354
    OC\Files\ObjectStore\ObjectStoreStorage->touch("appdata_ochey15 ... s", 1589427415)
11. /var/www/nextcloud/lib/private/Files/Storage/Wrapper/Availability.php line 364
    OC\Files\Storage\Wrapper\Wrapper->touch("appdata_ochey15 ... s", null)
12. /var/www/nextcloud/lib/private/Files/Storage/Wrapper/Wrapper.php line 354
    OC\Files\Storage\Wrapper\Availability->touch("appdata_ochey15 ... s", null)
13. /var/www/nextcloud/lib/private/Files/View.php line 1162
    OC\Files\Storage\Wrapper\Wrapper->touch("appdata_ochey15 ... s")
14. /var/www/nextcloud/lib/private/Files/View.php line 569
    OC\Files\View->basicOperation("touch", "/appdata_ochey1 ... s", ["touch","create","write"], null)
15. /var/www/nextcloud/lib/private/Files/Node/Folder.php line 184
    OC\Files\View->touch("/appdata_ochey1 ... s")
16. /var/www/nextcloud/lib/private/Files/SimpleFS/SimpleFolder.php line 84
    OC\Files\Node\Folder->newFile("47cd-aef3-globalstyles.css")
17. /var/www/nextcloud/lib/private/Template/SCSSCacher.php line 312
    OC\Files\SimpleFS\SimpleFolder->newFile("47cd-aef3-globalstyles.css")
18. /var/www/nextcloud/lib/private/Template/SCSSCacher.php line 182
    OC\Template\SCSSCacher->cache("/var/www/nextcloud/apps/deck/css", "47cd-aef3-globalstyles.css", "globalstyles.scss", OC\Files\SimpleFS\SimpleFolder {}, "/apps/deck/css")
19. /var/www/nextcloud/lib/private/Template/CSSResourceLocator.php line 110
    OC\Template\SCSSCacher->process("/var/www/nextcloud/apps/deck", "css/globalstyles.scss", "deck")
20. /var/www/nextcloud/lib/private/Template/CSSResourceLocator.php line 85
    OC\Template\CSSResourceLocator->cacheAndAppendScssIfExist("/var/www/nextcloud/apps/deck", "css/globalstyles.scss", "deck")
21. /var/www/nextcloud/lib/private/Template/ResourceLocator.php line 78
    OC\Template\CSSResourceLocator->doFind("css/globalstyles")
22. /var/www/nextcloud/lib/private/TemplateLayout.php line 310
    OC\Template\ResourceLocator->find(["css/server","c ... "])
23. /var/www/nextcloud/lib/private/TemplateLayout.php line 215
    OC\TemplateLayout::findStylesheetFiles(["css/server","c ... "])
24. /var/www/nextcloud/lib/private/legacy/template.php line 184
    OC\TemplateLayout->__construct("user", "deck")
25. /var/www/nextcloud/lib/public/AppFramework/Http/TemplateResponse.php line 167
    OC_Template->fetchPage([])
26. /var/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php line 123
    OCP\AppFramework\Http\TemplateResponse->render()
27. /var/www/nextcloud/lib/private/AppFramework/App.php line 125
    OC\AppFramework\Http\Dispatcher->dispatch(OCA\Deck\Controller\PageController {}, "index")
28. /var/www/nextcloud/lib/private/AppFramework/Routing/RouteActionHandler.php line 47
    OC\AppFramework\App::main("OCA\\Deck\\Controller\\PageController", "index", OC\AppFramework\ ... {}, {_route: "deck.page.index"})
29. <<closure>>
    OC\AppFramework\Routing\RouteActionHandler->__invoke({_route: "deck.page.index"})
30. /var/www/nextcloud/lib/private/Route/Router.php line 299
    call_user_func(OC\AppFramework\ ... {}, {_route: "deck.page.index"})
31. /var/www/nextcloud/lib/base.php line 1008
    OC\Route\Router->match("/apps/deck/")
32. /var/www/nextcloud/index.php line 38
    OC::handleRequest()

GET /apps/deck/
from {redacted} by {redacted} at 2020-05-14T03:36:55+00:00
solracsf commented 4 years ago

Other errors while generating previews, this is completely spamming logs.

``` { "reqId":"5vcAs5ewP67xATu5LDnt", "level":3, "time":"2020-05-17T12:03:54+02:00", "remoteAddr":"176.157.55.153", "user":"celin", "app":"index", "method":"GET", "url":"/core/preview.png?file=/Communication%20externe/R%C3%A9seaux%20sociaux/Instagram/Instafeed1_Image1.jpg&c=5ec10c08544ea&x=150&y=150", "message":{ "Exception":"Exception", "Message":"Argument 1 passed to OC\\Files\\Cache\\CacheQueryBuilder::whereFileId() must be of the type int, null given, called in /nextcloud/lib/private/Files/Cache/Cache.php on line 655", "Code":0, "Trace":[ { "file":"/nextcloud/lib/private/AppFramework/App.php", "line":125, "function":"dispatch", "class":"OC\\AppFramework\\Http\\Dispatcher", "type":"->", "args":[ { "__class__":"OC\\Core\\Controller\\PreviewController" }, "getPreview" ] }, { "file":"/nextcloud/lib/private/AppFramework/Routing/RouteActionHandler.php", "line":47, "function":"main", "class":"OC\\AppFramework\\App", "type":"::", "args":[ "OC\\Core\\Controller\\PreviewController", "getPreview", { "__class__":"OC\\AppFramework\\DependencyInjection\\DIContainer" }, { "_route":"core.Preview.getPreview" } ] }, { "function":"__invoke", "class":"OC\\AppFramework\\Routing\\RouteActionHandler", "type":"->", "args":[ { "_route":"core.Preview.getPreview" } ] }, { "file":"/nextcloud/lib/private/Route/Router.php", "line":299, "function":"call_user_func", "args":[ { "__class__":"OC\\AppFramework\\Routing\\RouteActionHandler" }, { "_route":"core.Preview.getPreview" } ] }, { "file":"/nextcloud/lib/base.php", "line":1008, "function":"match", "class":"OC\\Route\\Router", "type":"->", "args":[ "/core/preview.png" ] }, { "file":"/nextcloud/index.php", "line":38, "function":"handleRequest", "class":"OC", "type":"::", "args":[ ] } ], "File":"/nextcloud/lib/private/AppFramework/Http/Dispatcher.php", "Line":109, "Previous":{ "Exception":"TypeError", "Message":"Argument 1 passed to OC\\Files\\Cache\\CacheQueryBuilder::whereFileId() must be of the type int, null given, called in /nextcloud/lib/private/Files/Cache/Cache.php on line 655", "Code":0, "Trace":[ { "file":"/nextcloud/lib/private/Files/Cache/Cache.php", "line":655, "function":"whereFileId", "class":"OC\\Files\\Cache\\CacheQueryBuilder", "type":"->", "args":[ null ] }, { "file":"/nextcloud/lib/private/Files/Cache/Cache.php", "line":579, "function":"moveFromCache", "class":"OC\\Files\\Cache\\Cache", "type":"->", "args":[ { "__class__":"OC\\Files\\Cache\\Cache" }, "appdata_oca0jwbfgo3r/preview/2052/256-256-crop.jpg.part", "appdata_oca0jwbfgo3r/preview/2052/256-256-crop.jpg" ] }, { "file":"/nextcloud/lib/private/Files/ObjectStore/ObjectStoreStorage.php", "line":476, "function":"move", "class":"OC\\Files\\Cache\\Cache", "type":"->", "args":[ "appdata_oca0jwbfgo3r/preview/2052/256-256-crop.jpg.part", "appdata_oca0jwbfgo3r/preview/2052/256-256-crop.jpg" ] }, { "file":"/nextcloud/lib/private/Files/ObjectStore/ObjectStoreStorage.php", "line":400, "function":"writeStream", "class":"OC\\Files\\ObjectStore\\ObjectStoreStorage", "type":"->", "args":[ "appdata_oca0jwbfgo3r/preview/2052/256-256-crop.jpg", null, 1 ] }, { "file":"/nextcloud/lib/private/Files/ObjectStore/ObjectStoreStorage.php", "line":313, "function":"writeBack", "class":"OC\\Files\\ObjectStore\\ObjectStoreStorage", "type":"->", "args":[ "/tmp/oc_tmp_xJwtm2-.jpg", "appdata_oca0jwbfgo3r/preview/2052/256-256-crop.jpg" ] }, { "function":"OC\\Files\\ObjectStore\\{closure}", "class":"OC\\Files\\ObjectStore\\ObjectStoreStorage", "type":"->", "args":[ "*** sensitive parameters replaced ***" ] }, { "file":"/nextcloud/3rdparty/icewind/streams/src/CallbackWrapper.php", "line":121, "function":"call_user_func", "args":[ { "__class__":"Closure" } ] }, { "function":"stream_close", "class":"Icewind\\Streams\\CallbackWrapper", "type":"->", "args":[ ] }, { "file":"/nextcloud/lib/private/Files/ObjectStore/ObjectStoreStorage.php", "line":421, "function":"fclose", "args":[ null ] }, { "file":"/nextcloud/lib/private/Files/ObjectStore/ObjectStoreStorage.php", "line":376, "function":"file_put_contents", "class":"OC\\Files\\ObjectStore\\ObjectStoreStorage", "type":"->", "args":[ "appdata_oca0jwbfgo3r/preview/2052/256-256-crop.jpg", " " ] }, { "file":"/nextcloud/lib/private/Files/Storage/Wrapper/Wrapper.php", "line":354, "function":"touch", "class":"OC\\Files\\ObjectStore\\ObjectStoreStorage", "type":"->", "args":[ "appdata_oca0jwbfgo3r/preview/2052/256-256-crop.jpg", 1589709833 ] }, { "file":"/nextcloud/lib/private/Files/Storage/Wrapper/Availability.php", "line":364, "function":"touch", "class":"OC\\Files\\Storage\\Wrapper\\Wrapper", "type":"->", "args":[ "appdata_oca0jwbfgo3r/preview/2052/256-256-crop.jpg", null ] }, { "file":"/nextcloud/lib/private/Files/Storage/Wrapper/Wrapper.php", "line":354, "function":"touch", "class":"OC\\Files\\Storage\\Wrapper\\Availability", "type":"->", "args":[ "appdata_oca0jwbfgo3r/preview/2052/256-256-crop.jpg", null ] }, { "file":"/nextcloud/apps/ransomware_protection/lib/StorageWrapper.php", "line":373, "function":"touch", "class":"OC\\Files\\Storage\\Wrapper\\Wrapper", "type":"->", "args":[ "appdata_oca0jwbfgo3r/preview/2052/256-256-crop.jpg", null ] }, { "file":"/nextcloud/lib/private/Files/View.php", "line":1162, "function":"touch", "class":"OCA\\RansomwareProtection\\StorageWrapper", "type":"->", "args":[ "appdata_oca0jwbfgo3r/preview/2052/256-256-crop.jpg" ] }, { "file":"/nextcloud/lib/private/Files/View.php", "line":569, "function":"basicOperation", "class":"OC\\Files\\View", "type":"->", "args":[ "touch", "/appdata_oca0jwbfgo3r/preview/2052/256-256-crop.jpg", [ "touch", "create", "write" ], null ] }, { "file":"/nextcloud/lib/private/Files/Node/Folder.php", "line":184, "function":"touch", "class":"OC\\Files\\View", "type":"->", "args":[ "/appdata_oca0jwbfgo3r/preview/2052/256-256-crop.jpg" ] }, { "file":"/nextcloud/lib/private/Files/SimpleFS/SimpleFolder.php", "line":84, "function":"newFile", "class":"OC\\Files\\Node\\Folder", "type":"->", "args":[ "256-256-crop.jpg" ] }, { "file":"/nextcloud/lib/private/Preview/Generator.php", "line":397, "function":"newFile", "class":"OC\\Files\\SimpleFS\\SimpleFolder", "type":"->", "args":[ "256-256-crop.jpg" ] }, { "file":"/nextcloud/lib/private/Preview/Generator.php", "line":154, "function":"generatePreview", "class":"OC\\Preview\\Generator", "type":"->", "args":[ { "__class__":"OC\\Files\\SimpleFS\\SimpleFolder" }, { "__class__":"OC\\Files\\SimpleFS\\SimpleFile" }, 256, 256, true, 591, 591, "" ] }, { "file":"/nextcloud/lib/private/PreviewManager.php", "line":185, "function":"getPreview", "class":"OC\\Preview\\Generator", "type":"->", "args":[ { "__class__":"OC\\Files\\Node\\File" }, 256, 256, true, "fill", "image/jpeg" ] }, { "file":"/nextcloud/core/Controller/PreviewController.php", "line":172, "function":"getPreview", "class":"OC\\PreviewManager", "type":"->", "args":[ { "__class__":"OC\\Files\\Node\\File" }, 150, 150, true, "fill" ] }, { "file":"/nextcloud/core/Controller/PreviewController.php", "line":107, "function":"fetchPreview", "class":"OC\\Core\\Controller\\PreviewController", "type":"->", "args":[ { "__class__":"OC\\Files\\Node\\File" }, 150, 150, false, true, "fill" ] }, { "file":"/nextcloud/lib/private/AppFramework/Http/Dispatcher.php", "line":170, "function":"getPreview", "class":"OC\\Core\\Controller\\PreviewController", "type":"->", "args":[ "/Communication externe/R\u00e9seaux sociaux/Instagram/Wutao_Instafeed1_Image1.jpg", 150, 150, false, true, "fill" ] }, { "file":"/nextcloud/lib/private/AppFramework/Http/Dispatcher.php", "line":99, "function":"executeController", "class":"OC\\AppFramework\\Http\\Dispatcher", "type":"->", "args":[ { "__class__":"OC\\Core\\Controller\\PreviewController" }, "getPreview" ] }, { "file":"/nextcloud/lib/private/AppFramework/App.php", "line":125, "function":"dispatch", "class":"OC\\AppFramework\\Http\\Dispatcher", "type":"->", "args":[ { "__class__":"OC\\Core\\Controller\\PreviewController" }, "getPreview" ] }, { "file":"/nextcloud/lib/private/AppFramework/Routing/RouteActionHandler.php", "line":47, "function":"main", "class":"OC\\AppFramework\\App", "type":"::", "args":[ "OC\\Core\\Controller\\PreviewController", "getPreview", { "__class__":"OC\\AppFramework\\DependencyInjection\\DIContainer" }, { "_route":"core.Preview.getPreview" } ] }, { "function":"__invoke", "class":"OC\\AppFramework\\Routing\\RouteActionHandler", "type":"->", "args":[ { "_route":"core.Preview.getPreview" } ] }, { "file":"/nextcloud/lib/private/Route/Router.php", "line":299, "function":"call_user_func", "args":[ { "__class__":"OC\\AppFramework\\Routing\\RouteActionHandler" }, { "_route":"core.Preview.getPreview" } ] }, { "file":"/nextcloud/lib/base.php", "line":1008, "function":"match", "class":"OC\\Route\\Router", "type":"->", "args":[ "/core/preview.png" ] }, { "file":"/nextcloud/index.php", "line":38, "function":"handleRequest", "class":"OC", "type":"::", "args":[ ] } ], "File":"/nextcloud/lib/private/Files/Cache/CacheQueryBuilder.php", "Line":66 }, "CustomMessage":"--" }, "userAgent":"Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:76.0) Gecko/20100101 Firefox/76.0", "version":"18.0.4.2" } ```
williamsmt commented 4 years ago

@acsfer - when repro’d, are you presented with a 500 error?

evan-a-a commented 4 years ago

I'm able to reproduce this problem when attempting to run encryption:encrypt-all on an instance with S3 backed storage. ~It's consistently failing at the same file.~ Update, doesn't appear to be the case as I just got a different file failure.

TypeError: Argument 1 passed to OC\Files\Cache\CacheQueryBuilder::whereFileId() must be of the type int, null given, called in /var/www/html/lib/private/Files/Cache/Cache.php on line 661 and defined in /var/www/html/lib/private/Files/Cache/CacheQueryBuilder.php:66
Stack trace:
#0 /var/www/html/lib/private/Files/Cache/Cache.php(661): OC\Files\Cache\CacheQueryBuilder->whereFileId(NULL)
#1 /var/www/html/lib/private/Files/Cache/Cache.php(585): OC\Files\Cache\Cache->moveFromCache(Object(OC\Files\Cache\Cache), 'files/Google/Ta...', 'files/Google/Ta...')
#2 /var/www/html/lib/private/Files/ObjectStore/ObjectStoreStorage.php(347): OC\Files\Cache\Cache->move('files/Google/Ta...', 'files/Google/Ta...')
#3 /var/www/html/lib/private/Files/Storage/Wrapper/Wrapper.php(278): OC\Files\ObjectStore\ObjectStoreStorage->rename('files/Google/Ta...', 'files/Google/Ta...')
#4 /var/www/html/lib/private/Files/Storage/Wrapper/Availability.php(295): OC\Files\Storage\Wrapper\Wrapper->rename('files/Google/Ta...', 'files/Google/Ta...')
#5 /var/www/html/lib/private/Files/Storage/Wrapper/Encryption.php(280): OC\Files\Storage\Wrapper\Availability->rename('files/Google/Ta...', 'files/Google/Ta...')
#6 /var/www/html/lib/private/Files/View.php(816): OC\Files\Storage\Wrapper\Encryption->rename('files/Google/Ta...', 'files/Google/Ta...')
#7 /var/www/html/apps/encryption/lib/Crypto/EncryptAll.php(307): OC\Files\View->rename('/evan/files/Goo...', '/evan/files/Goo...')
#8 /var/www/html/apps/encryption/lib/Crypto/EncryptAll.php(279): OCA\Encryption\Crypto\EncryptAll->encryptFile('/evan/files/Goo...')
#9 /var/www/html/apps/encryption/lib/Crypto/EncryptAll.php(249): OCA\Encryption\Crypto\EncryptAll->encryptUsersFiles('evan', Object(Symfony\Component\Console\Helper\ProgressBar), 'evan (1)')
#10 /var/www/html/apps/encryption/lib/Crypto/EncryptAll.php(223): OCA\Encryption\Crypto\EncryptAll->encryptAllUserFilesWithMasterKey(Object(Symfony\Component\Console\Helper\ProgressBar))
#11 /var/www/html/apps/encryption/lib/Crypto/EncryptAll.php(173): OCA\Encryption\Crypto\EncryptAll->encryptAllUsersFiles()
#12 /var/www/html/apps/encryption/lib/Crypto/Encryption.php(511): OCA\Encryption\Crypto\EncryptAll->encryptAll(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#13 /var/www/html/core/Command/Encryption/EncryptAll.php(135): OCA\Encryption\Crypto\Encryption->encryptAll(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#14 /var/www/html/3rdparty/symfony/console/Command/Command.php(255): OC\Core\Command\Encryption\EncryptAll->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#15 /var/www/html/3rdparty/symfony/console/Application.php(1012): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#16 /var/www/html/3rdparty/symfony/console/Application.php(272): Symfony\Component\Console\Application->doRunCommand(Object(OC\Core\Command\Encryption\EncryptAll), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#17 /var/www/html/3rdparty/symfony/console/Application.php(148): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#18 /var/www/html/lib/private/Console/Application.php(215): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#19 /var/www/html/console.php(100): OC\Console\Application->run()
#20 /var/www/html/occ(11): require_once('/var/www/html/c...')
solracsf commented 4 years ago

@acsfer - when repro’d, are you presented with a 500 error?

Not always, but in some cases, yes.

vpecinka commented 4 years ago

Same here - trying to remove folder from group folder with error:

{"reqId":"3g9lsTqI5CGvvIjsNwof","level":3,"time":"2020-09-15T15:45:35+00:00","remoteAddr":"10.72.23.57","user":"C25706B5-6F13-4480-B6AF-58758421425A","app":"remote","method":"DELETE","url":"/remote.php/dav/files/C25706B5-6F13-4480-B6AF-58758421425A/%C3%9A%C4%8Detn%C3%AD%20-%20t%C3%BDm/vp-pokus","message":{"Exception":"TypeError","Message":"Argument 1 passed to OC\\Files\\Cache\\CacheQueryBuilder::whereFileId() must be of the type int, null given, called in /www/nextcloud/lib/private/Files/Cache/Cache.php on line 655"

The folder vp-pokus was successfully created over web interface and trying to be removed.

vpecinka commented 4 years ago

It seems that direcotry/file is removed, just this exception means web ui or sync errors. Small hot fix (don't now if this is proper solution) is as follows:

--- lib/private/Files/Cache/Cache.php.orig  2020-09-15 21:37:02.746915649 +0200
+++ lib/private/Files/Cache/Cache.php   2020-09-15 21:36:50.565788163 +0200
@@ -645,6 +645,7 @@
                }
            }

+           if ($sourceId) {
            $query = $this->getQueryBuilder();
            $query->update('filecache')
                ->set('storage', $query->createNamedParameter($targetStorageId))
@@ -654,6 +655,7 @@
                ->set('parent', $query->createNamedParameter($newParentId, IQueryBuilder::PARAM_INT))
                ->whereFileId($sourceId);
            $query->execute();
+           }

            $this->connection->commit();
        } else {
solracsf commented 4 years ago

@vpecinka mind to open a PR to review?

vpecinka commented 4 years ago

Well, I'm not sure this is a valid solution. It is a hotfix but the real question is why the $sourceId is null in this case.

May you change the Cache.php locally and confirm that this condition if ($sourceId) { works for you as well?

solracsf commented 4 years ago

Ok thanks; do you have a test case? My previous test case is not valid anymore in 19.0.3; it now trows an "Lock" warning and not the "CacheQueryBuilder" error.

image

vpecinka commented 4 years ago

I am able to reproduce this error on 18.0.9 while using "group folders" app

  1. as admin create a group folder (e.g. my_test) and add yourself (a group you are member of) to it
  2. create a subfolder in it and a test txt file (e.g. my_test\sub\test.txt)
  3. try to remove the subfolder sub
  4. you got HTTP 500, but after refresh you can see the folder is gone (and placed to trash bin)
solracsf commented 3 years ago

@vpecinka i was able to test it today using https://github.com/nextcloud/server/issues/19009#issuecomment-693532936 and confirm if ($sourceId) { works here.

szaimen commented 3 years ago

I cannot reproduce this https://github.com/nextcloud/server/issues/19009#issuecomment-693532936 on NC21.0.2 If this is still happening please make sure to upgrade to the latest version. After that, feel free to reopen. The latest version can be seen by checking https://nextcloud.com/install/#install-clients and https://nextcloud.com/install/#instructions-server respectively.

brainchild0 commented 1 year ago

I am reproducing the problem, in Nextcloud 27 (27.0.1.2).

It is running with MariaDB 10.2 (10.2.31), PHP 8.0 (8.0.26), under CentOS 7 (7.9.2009).

I have further attempted the process after a sequence of operations, including files:cleanup, files:repair-tree, and files:scan, but such preparations produce no improvement.

Once the error occurs, I must restore the entire deployment from backup, because even thought the file store is only partially decrypted, subsequent calls to the same command for decryption report that the store is no longer encrypted, and performs no action.

The message shown for subsequent attempts to decrypt is as follows:

Server side encryption not enabled. Nothing to do