Notes: Issue Creating New Notes when using Object Storage

Created on 18 Jun 2019  ·  22Comments  ·  Source: nextcloud/notes

After upgrading from Nextcloud 15 to 16, the Notes webapp throws an error when I click on the 'New note' button.
image

Here is the stacktrace from the logs:

[index] Error: OCP\Files\GenericFileException: file_put_contents failed at <>

  1. /var/www/html/custom_apps/notes/lib/Service/NotesService.php line 193
    OC\Files\Node\File->putContent("* sensitive parameter replaced *")
  2. /var/www/html/custom_apps/notes/lib/Controller/NotesController.php line 129
    OCA\Notes\Service\NotesService->update("* sensitive parameters replaced *")
  3. /var/www/html/lib/private/AppFramework/Http/Dispatcher.php line 166
    OCA\Notes\Controller\NotesController->create("* sensitive parameter replaced ", " sensitive parameter replaced *")
  4. /var/www/html/lib/private/AppFramework/Http/Dispatcher.php line 99
    OC\AppFramework\Http\Dispatcher->executeController(OCA\Notes\Controller\NotesController {}, "create")
  5. /var/www/html/lib/private/AppFramework/App.php line 126
    OC\AppFramework\Http\Dispatcher->dispatch(OCA\Notes\Controller\NotesController {}, "create")
  6. /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"})
  7. <>
    OC\AppFramework\Routing\RouteActionHandler->__invoke({_route: "notes.notes.create"})
  8. /var/www/html/lib/private/Route/Router.php line 297
    undefinedundefinedcall_user_func(OC\AppFramework\ ... {}, {_route: "notes.notes.create"})
  9. /var/www/html/lib/base.php line 975
    OC\Route\Router->match("/apps/notes/notes")
  10. /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

bug

All 22 comments

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?

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.

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.

[index] Error: OCP\Files\GenericFileException: file_put_contents failed at <<closure>>

0. /var/www/html/custom_apps/notes/lib/Service/NotesService.php line 193
   OC\Files\Node\File->putContent("*** sensitive parameter replaced ***")
1. /var/www/html/custom_apps/notes/lib/Controller/NotesController.php line 129
   OCA\Notes\Service\NotesService->update("*** sensitive parameters replaced ***")
2. /var/www/html/lib/private/AppFramework/Http/Dispatcher.php line 166
   OCA\Notes\Controller\NotesController->create("*** sensitive parameter replaced ***", "*** sensitive parameter replaced ***")
3. /var/www/html/lib/private/AppFramework/Http/Dispatcher.php line 99
   OC\AppFramework\Http\Dispatcher->executeController(OCA\Notes\Controller\NotesController {}, "create")
4. /var/www/html/lib/private/AppFramework/App.php line 126
   OC\AppFramework\Http\Dispatcher->dispatch(OCA\Notes\Controller\NotesController {}, "create")
5. /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"})
6. <<closure>>
   OC\AppFramework\Routing\RouteActionHandler->__invoke({_route: "notes.notes.create"})
7. /var/www/html/lib/private/Route/Router.php line 297
   undefinedundefinedcall_user_func(OC\AppFramework\ ... {}, {_route: "notes.notes.create"})
8. /var/www/html/lib/base.php line 975
   OC\Route\Router->match("/apps/notes/notes")
9. /var/www/html/index.php line 42
   OC::handleRequest()

POST /apps/notes/notes
from 178.197.232.91 by severin at 2019-07-09T19:00:58+00:00

@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...

@jkuester Yes I do. I use DigitalOcean Spaces as primary storage.

That's interesting, maybe we are going nearer to the source of the problem.

@jkuester Do you use DigitalOcean Spaces, too?

@jkuester @severinkaderli

  • Does this happen every time you create a note or only sometimes?
  • When you reload the page, is the new note completely empty or does it contain a single space ?

@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.

@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.

I am using OVH Public Cloud OpenStack Swift as Primary Storage and I am getting the same error.

On Nextcloud 15.0.10

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.

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.

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/

I think using a DigitalOcean referral code will give you $50 credit for a month, if that's an option for you?

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.

Another possibility might be Minio, a self-hosted object storage.

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.

Another possibility might be Minio, a self-hosted object storage.

I'm not sure the bug affects S3 or just OpenStack Swift though.

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).

I'm able to create new text files just fine in the Files app.

@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.

Nice, @marcelklehr ! Thanks for your great analysis! :tada:

One question: will #343 still be required after merging nextcloud/server#16397 ?

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 :man_shrugging:

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.

Server PR is merged 😉

Nice, the issue was fixed in Nextcloud Server for Nextcloud 15, 16 and 17. :tada: 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 !

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Larsene picture Larsene  ·  6Comments

korelstar picture korelstar  ·  3Comments

kees-closed picture kees-closed  ·  7Comments

Beta0815 picture Beta0815  ·  6Comments

CodeAlDente picture CodeAlDente  ·  3Comments