Repository navigation
Issue Creating New Notes when using Object Storage #326
Description
After upgrading from Nextcloud 15 to 16, the Notes webapp throws an error when I click on the 'New note' button.

Here is the stacktrace from the logs:
[index] Error: OCP\Files\GenericFileException: file_put_contents failed at <>
- /var/www/html/custom_apps/notes/lib/Service/NotesService.php line 193
OC\Files\Node\File->putContent("*** sensitive parameter replaced ***")- /var/www/html/custom_apps/notes/lib/Controller/NotesController.php line 129
OCA\Notes\Service\NotesService->update("*** sensitive parameters replaced ***")- /var/www/html/lib/private/AppFramework/Http/Dispatcher.php line 166
OCA\Notes\Controller\NotesController->create("*** sensitive parameter replaced ", " sensitive parameter replaced ***")- /var/www/html/lib/private/AppFramework/Http/Dispatcher.php line 99
OC\AppFramework\Http\Dispatcher->executeController(OCA\Notes\Controller\NotesController {}, "create")- /var/www/html/lib/private/AppFramework/App.php line 126
OC\AppFramework\Http\Dispatcher->dispatch(OCA\Notes\Controller\NotesController {}, "create")- /var/www/html/lib/private/AppFramework/Routing/RouteActionHandler.php line 47
OC\AppFramework\App::main("OCA\Notes\Controller\NotesController", "create", OC\AppFramework\ ... {}, {_route: "notes.notes.create"})- <>
OC\AppFramework\Routing\RouteActionHandler->__invoke({_route: "notes.notes.create"})- /var/www/html/lib/private/Route/Router.php line 297
undefinedundefinedcall_user_func(OC\AppFramework\ ... {}, {_route: "notes.notes.create"})- /var/www/html/lib/base.php line 975
OC\Route\Router->match("/apps/notes/notes")- /var/www/html/index.php line 42
OC::handleRequest()POST /index.php/apps/notes/notes
I tried removing the app and reinstalling it, but still get the same error. The interesting thing is that the new note is actually created and will show up in the webapp if the page is refreshed.
Any suggestions would be much appreciated! Thank you!
Server configuration detail
Operating system: Linux 4.15.0-50-generic #54-Ubuntu SMP Mon May 6 18:46:08 UTC 2019 x86_64
Webserver: Caddy/v1.0.0 (fpm-fcgi)
Database: pgsql PostgreSQL 10.8 on x86_64-pc-linux-musl, compiled by gcc (Alpine 8.3.0) 8.3.0, 64-bit
PHP version: 7.3.6
Modules loaded: Core, date, libxml, openssl, pcre, sqlite3, zlib, ctype, curl, dom, fileinfo, filter, ftp, hash, iconv, json, mbstring, SPL, PDO, session, posix, readline, Reflection, standard, SimpleXML, pdo_sqlite, Phar, tokenizer, xml, xmlreader, xmlwriter, mysqlnd, cgi-fcgi, apcu, exif, gd, imagick, intl, ldap, memcached, pcntl, pdo_mysql, pdo_pgsql, redis, sodium, zip, Zend OPcache
Nextcloud version: 16.0.1 - 16.0.1.1
External storages: yes
Encryption: no
Browser: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.90 Safari/537.36
Activity
korelstar commentedon Jun 19, 2019
Thanks for reporting this issue. Unfortunately, I can't reproduce this and I can't see anything in the log which could help to create a fix.
Does anybody else have this problem, too?
jkuester commentedon Jun 24, 2019
Okay, thanks for taking a look! Figured I would leave this open a bit to see if anyone else had seen this issue. Seeing as there were no takers, I am going to close it.
severinkaderli commentedon Jul 9, 2019
I actually have the same issue on a fresh NC 16 install. After clicking on "New Note" an error is shown, but the note is created after refreshing the page.
jkuester commentedon Jul 9, 2019
@severinkaderli Out of curiosity, are you using some S3 provider as your primary storage? I am doing so and I am wondering if perhaps there could be some kind of bad reaction there.
It is just strange since, as you said, the notes do show up after a page refresh. I do not have any issues creating files in the Notes folder using the Files app or the Notes Android app...
severinkaderli commentedon Jul 10, 2019
@jkuester Yes I do. I use DigitalOcean Spaces as primary storage.
korelstar commentedon Jul 10, 2019
That's interesting, maybe we are going nearer to the source of the problem.
@jkuester Do you use DigitalOcean Spaces, too?
@jkuester @severinkaderli
?[-]Issue Creating New Notes with NC 16[/-][+]Issue Creating New Notes when using Object Storage[/+]martyschaer commentedon Jul 10, 2019
@korelstar I'm on the same instance as @severinkaderli.
The new note file is 0B in size, = Empty.
It happens every time I wish to create a note.
jkuester commentedon Jul 10, 2019
@korelstar Yes! I am also using DigitalOcean Spaces. Also, my behavior matches @martyschaer. The error happens every time I create a new note and the new note file is empty (not even a single space).
Not sure if it matters or not, but I also noticed that the note is created when the "New note" button is pressed, but it just does not show up in the Notes app until the page is refreshed. If I press the "New note" button and then switch to the Files app without reloading the Notes app, I can see the newly created note file in my Notes folder. Also, in the Notes app if I press the "New note" button multiple times without reloading the page, I get the same error each time. Then when I reload the page there is a new note for each time that I pressed the button.
llebout commentedon Jul 11, 2019
I am using OVH Public Cloud OpenStack Swift as Primary Storage and I am getting the same error.
On Nextcloud 15.0.10
korelstar commentedon Jul 12, 2019
Is there a S3 provider with a free plan / trial period on which this issue occurs? This would be helpful for me to find a fix.
llebout commentedon Jul 12, 2019
I don't think so, unfortunately, I am not the one with the funds to provide you with an OpenStack Swift endpoint here.
You can try setting up devstack: https://docs.openstack.org/devstack/latest/
martyschaer commentedon Jul 12, 2019
I think using a DigitalOcean referral code will give you $50 credit for a month, if that's an option for you?
severinkaderli commentedon Jul 12, 2019
Another possibility might be Minio, a self-hosted object storage.
llebout commentedon Jul 12, 2019
I'm not sure the bug affects S3 or just OpenStack Swift though.
marcelklehr commentedon Jul 13, 2019
I was curious and did some digging and came up with a theory for this. It appears that the ObjectStore Storage implementation puts the file contents into the php temp stream, which is passed to the S3 uploader, which for whatever reason tries to reopen the underlying file of the stream, which happens to be the php temp stream, which is not reusable by passing its uri and is thus empty. It's quite late, so I'm not sure if I'm completely off, but if the theory is correct, it predicts that you might also not be able to create text files with the files app (if the files app is not using some sort of streaming upload for those that requires creating a temp file).
martyschaer commentedon Jul 13, 2019
I'm able to create new text files just fine in the Files app.
marcelklehr commentedon Jul 13, 2019
@martyschaer Mh. That may be due to the way the files app works. SInce it uses WebDAV there probably are differences, which render the prediction inapplicable.
A quick fix, if the above theory is correct, would be to pass the contents as a stream to putContents(), which forces nextcloud to write the stream to disk in a temp file and thus avoids the failing S3 upload, as the aws uploader now has an actual file to work with instead of the temp stream.
Potential fix for #326
korelstar commentedon Jul 15, 2019
Nice, @marcelklehr ! Thanks for your great analysis! 🎉
One question: will #343 still be required after merging nextcloud/server#16397 ?
marcelklehr commentedon Jul 15, 2019
I'm happy to help :) The notes pr is not required for those releases of nextcloud that have the patch, but for backwards compatiblity you might want to use it anyway. But then again, the nextcloud pr might get backported, so 🤷♂️
korelstar commentedon Jul 16, 2019
Thanks, let's see if my backport request will be fulfilled. I think that would be better than having a temporary workaround in the notes app.
MorrisJobke commentedon Jul 17, 2019
Server PR is merged 😉
korelstar commentedon Jul 18, 2019
Nice, the issue was fixed in Nextcloud Server for Nextcloud 15, 16 and 17. 🎉 Please install the next server (patch) release.
I'm closing this issue now, since we don't need a workaround patch in the notes app anymore. Thanks again to @marcelklehr !