Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to generate token for existing file on direct editing error #2681

Closed
l3ochan opened this issue Dec 11, 2022 · 12 comments
Closed

Failed to generate token for existing file on direct editing error #2681

l3ochan opened this issue Dec 11, 2022 · 12 comments
Labels
bug Something isn't working needs info

Comments

@l3ochan
Copy link

l3ochan commented Dec 11, 2022

Describe the bug
I can't open files on mobile devices such as android devices or IOS

To Reproduce
Steps to reproduce the behavior:

  1. Open your nextcloud app
  2. Create a new file
  3. The nextcloud documents app loads endlessly

Expected behavior
Document should open and I should be able to edit/see it

Client details:

  • OS: Android 13, but also tried on 2 android 10 devices
  • Device: Google Pixel 7 pro, Huaweil P30 Pro and Galaxy tab S5e

Server details

Operating system: Ubuntu server 22.04 lts

**Web server:**Apache

**Database:**MariaDB

**PHP version:**8.1.2

**Nextcloud version:**25.0.2

Version of the richdocuments app7.0.2

Version of Collabora OnlineThe latest

Logs

Nextcloud log (data/nextcloud.log)

Failed to generate token for existing file on direct editing
@LokeYourC3PH
Copy link

Started facing the same issue for no reason. Something's off.

@qroac
Copy link

qroac commented Jan 17, 2023

I just set up collabora/code with traefik, connected it to nextcloud and get the very same error.

It works fine when working in the browser.
But as soon as I open any document in the mobile app, I get this entry in my nextcloud log and no connection attempt to the collabora instance (logs in collabora docker container stay empty)

@qroac
Copy link

qroac commented Jan 17, 2023

@LokeYourLord and @Laitauxnards
Do you by chance use the guests app for external guests in your nextcloud instance?
I just checked the logfile in the filesystem for the full error stacktrace and it seems richdocuments somehow has quarrel with guests.
(See next post)

The error complains about an unknown DB column guest_displayname in field list

{"reqId":"6biMxhdJUH7GWWsNB3Do","level":4,"time":"2023-01-15T00:20:47+00:00","remoteAddr":"[[IPV6-ADDR]]","user":"--","app":"richdocuments","method":"GET","url":"/index.php/apps/richdocuments/direct/G6lwta6f1ncU4VHVgni204qV3UbhboP1sJm4jLcgrwixUD4SZUuhr4SGH2dDpcYb","message":"Failed to generate token for existing file on direct editing","userAgent":"Mozilla/5.0 (Android) Nextcloud-android/3.23.1","version":"24.0.7.1","data":{"exception":"{\"class\":\"Doctrine\\DBAL\\Exception\\InvalidFieldNameException\",\"message\":\"An exception occurred while executing a query: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'guest_displayname' in 'field list'\",\"code\":1054,\"file\":\"[[FOLDER]]/3rdparty/doctrine/dbal/src/Driver/API/MySQL/ExceptionConverter.php:65\",\"trace\":\"#0 [[FOLDER]]/3rdparty/doctrine/dbal/src/Connection.php(1780): Doctrine\\DBAL\\Driver\\API\\MySQL\\ExceptionConverter->convert()\
#1 [[FOLDER]]/3rdparty/doctrine/dbal/src/Connection.php(1719): Doctrine\\DBAL\\Connection->handleDriverException()\
#2 [[FOLDER]]/3rdparty/doctrine/dbal/src/Statement.php(193): Doctrine\\DBAL\\Connection->convertExceptionDuringQuery()\
#3 [[FOLDER]]/lib/private/DB/PreparedStatement.php(87): Doctrine\\DBAL\\Statement->execute()\
#4 [[FOLDER]]/lib/public/AppFramework/Db/Mapper.php(252): OC\\DB\\PreparedStatement->execute()\
#5 [[FOLDER]]/lib/public/AppFramework/Db/Mapper.php(127): OCP\\AppFramework\\Db\\Mapper->execute()\
#6 [[FOLDER]]/apps/richdocuments/lib/Db/WopiMapper.php(91): OCP\\AppFramework\\Db\\Mapper->insert()\
#7 [[FOLDER]]/apps/richdocuments/lib/TokenManager.php(209): OCA\\Richdocuments\\Db\\WopiMapper->generateFileToken()\
#8 [[FOLDER]]/apps/richdocuments/lib/Controller/DirectViewController.php(160): OCA\\Richdocuments\\TokenManager->getToken()\
#9 [[FOLDER]]/lib/private/AppFramework/Http/Dispatcher.php(225): OCA\\Richdocuments\\Controller\\DirectViewController->show()\
#10 [[FOLDER]]/lib/private/AppFramework/Http/Dispatcher.php(133): OC\\AppFramework\\Http\\Dispatcher->executeController()\
#11 [[FOLDER]]/lib/private/AppFramework/App.php(172): OC\\AppFramework\\Http\\Dispatcher->dispatch()\
#12 [[FOLDER]]/lib/private/Route/Router.php(298): OC\\AppFramework\\App::main()\
#13 [[FOLDER]]/lib/base.php(1030): OC\\Route\\Router->match()\
#14 [[FOLDER]]/index.php(36): OC::handleRequest()\
#15 {main}\",\"previous\":{\"class\":\"Doctrine\\DBAL\\Driver\\PDO\\Exception\",\"message\":\"SQLSTATE[42S22]: Column not found: 1054 Unknown column 'guest_displayname' in 'field list'\",\"code\":1054,\"file\":\"[[FOLDER]]/3rdparty/doctrine/dbal/src/Driver/PDO/Exception.php:26\",\"trace\":\"#0 [[FOLDER]]/3rdparty/doctrine/dbal/src/Driver/PDO/Statement.php(94): Doctrine\\DBAL\\Driver\\PDO\\Exception::new()\
#1 [[FOLDER]]/3rdparty/doctrine/dbal/src/Statement.php(189): Doctrine\\DBAL\\Driver\\PDO\\Statement->execute()\
#2 [[FOLDER]]/lib/private/DB/PreparedStatement.php(87): Doctrine\\DBAL\\Statement->execute()\
#3 [[FOLDER]]/lib/public/AppFramework/Db/Mapper.php(252): OC\\DB\\PreparedStatement->execute()\
#4 [[FOLDER]]/lib/public/AppFramework/Db/Mapper.php(127): OCP\\AppFramework\\Db\\Mapper->execute()\
#5 [[FOLDER]]/apps/richdocuments/lib/Db/WopiMapper.php(91): OCP\\AppFramework\\Db\\Mapper->insert()\
#6 [[FOLDER]]/apps/richdocuments/lib/TokenManager.php(209): OCA\\Richdocuments\\Db\\WopiMapper->generateFileToken()\
#7 [[FOLDER]]/apps/richdocuments/lib/Controller/DirectViewController.php(160): OCA\\Richdocuments\\TokenManager->getToken()\
#8 [[FOLDER]]/lib/private/AppFramework/Http/Dispatcher.php(225): OCA\\Richdocuments\\Controller\\DirectViewController->show()\
#9 [[FOLDER]]/lib/private/AppFramework/Http/Dispatcher.php(133): OC\\AppFramework\\Http\\Dispatcher->executeController()\
#10 [[FOLDER]]/lib/private/AppFramework/App.php(172): OC\\AppFramework\\Http\\Dispatcher->dispatch()\
#11 [[FOLDER]]/lib/private/Route/Router.php(298): OC\\AppFramework\\App::main()\
#12 [[FOLDER]]/lib/base.php(1030): OC\\Route\\Router->match()\
#13 [[FOLDER]]/index.php(36): OC::handleRequest()\
#14 {main}\",\"previous\":{\"class\":\"PDOException\",\"message\":\"SQLSTATE[42S22]: Column not found: 1054 Unknown column 'guest_displayname' in 'field list'\",\"code\":\"42S22\",\"file\":\"[[FOLDER]]/3rdparty/doctrine/dbal/src/Driver/PDO/Statement.php:92\",\"trace\":\"#0 [[FOLDER]]/3rdparty/doctrine/dbal/src/Driver/PDO/Statement.php(92): PDOStatement->execute()\
#1 [[FOLDER]]/3rdparty/doctrine/dbal/src/Statement.php(189): Doctrine\\DBAL\\Driver\\PDO\\Statement->execute()\
#2 [[FOLDER]]/lib/private/DB/PreparedStatement.php(87): Doctrine\\DBAL\\Statement->execute()\
#3 [[FOLDER]]/lib/public/AppFramework/Db/Mapper.php(252): OC\\DB\\PreparedStatement->execute()\
#4 [[FOLDER]]/lib/public/AppFramework/Db/Mapper.php(127): OCP\\AppFramework\\Db\\Mapper->execute()\
#5 [[FOLDER]]/apps/richdocuments/lib/Db/WopiMapper.php(91): OCP\\AppFramework\\Db\\Mapper->insert()\
#6 [[FOLDER]]/apps/richdocuments/lib/TokenManager.php(209): OCA\\Richdocuments\\Db\\WopiMapper->generateFileToken()\
#7 [[FOLDER]]/apps/richdocuments/lib/Controller/DirectViewController.php(160): OCA\\Richdocuments\\TokenManager->getToken()\
#8 [[FOLDER]]/lib/private/AppFramework/Http/Dispatcher.php(225): OCA\\Richdocuments\\Controller\\DirectViewController->show()\
#9 [[FOLDER]]/lib/private/AppFramework/Http/Dispatcher.php(133): OC\\AppFramework\\Http\\Dispatcher->executeController()\
#10 [[FOLDER]]/lib/private/AppFramework/App.php(172): OC\\AppFramework\\Http\\Dispatcher->dispatch()\
#11 [[FOLDER]]/lib/private/Route/Router.php(298): OC\\AppFramework\\App::main()\
#12 [[FOLDER]]/lib/base.php(1030): OC\\Route\\Router->match()\
#13 [[FOLDER]]/index.php(36): OC::handleRequest()\
#14 {main}\"}}}","app":"richdocuments"}}

@qroac
Copy link

qroac commented Jan 17, 2023

Update:
I couldn't find any hint on a field guest_displayname in the git repo of the guests app, but I found it in the richdocuments app

It appears in a DB migration script from October 3rd 22.
https://github.com/nextcloud/richdocuments/blob/c4c3c5fc6f510fe1656d5b0b52a3b9183201b61e/lib/Migration/Version2060Date20200302131958.php

I checked my richdocuments_wopi table.
The listed columns guest_displayname and is_remote_token are missing.
Instead I have a token_type column.

Appears to me there was an error during the upgrade.
Is there an OCC script to check for DB schema mismatch? Or should we just perform the changes of the migration by hand?

@qroac
Copy link

qroac commented Jan 17, 2023

Now for a test I added both missing fields from the migration to my database table.
Afterwards, the log complained about isRemoteToken being no vaild attribute.
"message":"Failed to validate WOPI access","userAgent":"COOLWSD HTTP Agent 22.05.9.2","version":"25.0.2.3","exception":{"Exception":"BadFunctionCallException","Message":"isRemoteToken is not a valid attribute"

So I removed it again and now I can open documents on my android phone using nextcloud app ...
Hope the missing field has no other sideeffects in the future. @juliushaertl might have had a reason for switching from token_type to is_remote_token ...

@l3ochan l3ochan closed this as completed Jan 17, 2023
@l3ochan l3ochan reopened this Jan 17, 2023
@LokeYourC3PH
Copy link

My issue was unrelated, as I figured out what had caused it. For me, I used CSP Editor to load certain scripts, and that broke mobile (but not web for some reason) document loading for me.

@l3ochan
Copy link
Author

l3ochan commented Apr 6, 2023

Hi, I didn't see that I got replies to my issues. So what was causing my issue is that I was using a program to bring back the real ips logging on my server. Since my server is hosted at home, I use cloudflare to "hide" my ip. But for logging purposes, I installed a software to bring back the actual ips from people connecting and not cloudflare's proxys servers. I had to uninstall it which fixed my issue. This is a bit annoying because if I get an attack, I have no way of knowing where its coming from...

@l3ochan l3ochan closed this as completed Apr 6, 2023
@l3ochan l3ochan reopened this Apr 6, 2023
@l3ochan
Copy link
Author

l3ochan commented Apr 10, 2023

Ok so after some time, now its doing the same thing again. Collabora is not working on mobile at all anymore and I don't have any logs entry. I don't know what to do now

@juliushaertl
Copy link
Member

Can you try again with the new releases from yesterday, this should be addressed with #2874

@mnheia
Copy link

mnheia commented May 17, 2023

Also experiencing this issue. Everything up to date (NC 26.0.1, Office 8.0.2, ...).

{"reqId":"4K4xiPr5vdA823naY8AR","level":4,"time":"2023-05-17T16:34:29+02:00","remoteAddr":"<IP>","user":"--","app":"richdocuments","method":"GET","url":"/apps/richdocuments/direct/lP8N5P5BMVgwywuDmJy31hHVV1fNQSXZ5ufc3RqJVdyxa9y27bESlC878NEVP9Vb","message":"Failed to generate token for existing file on direct editing","userAgent":"Mozilla/5.0 (Android) Nextcloud-android/3.24.2","version":"26.0.1.1","data":{"exception":"{\"class\":\"OCP\\Files\\NotPermittedException\",\"message\":\"\",\"code\":0,\"file\":\"/opt/nextcloud-26.0.1/apps/richdocuments/lib/TokenManager.php:187\",\"trace\":\"#0 /opt/nextcloud-26.0.1/apps/richdocuments/lib/Controller/DirectViewController.php(160): OCA\\Richdocuments\\TokenManager->getToken()\\n#1 /opt/nextcloud-26.0.1/lib/private/AppFramework/Http/Dispatcher.php(230): OCA\\Richdocuments\\Controller\\DirectViewController->show()\\n#2 /opt/nextcloud-26.0.1/lib/private/AppFramework/Http/Dispatcher.php(137): OC\\AppFramework\\Http\\Dispatcher->executeController()\\n#3 /opt/nextcloud-26.0.1/lib/private/AppFramework/App.php(183): OC\\AppFramework\\Http\\Dispatcher->dispatch()\\n#4 /opt/nextcloud-26.0.1/lib/private/Route/Router.php(315): OC\\AppFramework\\App::main()\\n#5 /opt/nextcloud-26.0.1/lib/base.php(1056): OC\\Route\\Router->match()\\n#6 /opt/nextcloud-26.0.1/index.php(36): OC::handleRequest()\\n#7 {main}\"}","app":"richdocuments"}}

Tried removing the app, cleaning the database and reinstalling. Same issue persist.

  • disable app
  • remove app folder
  • run the following sql statements:
  • drop table oc_richdocuments_direct;
  • drop table oc_richdocuments_wopi;
  • drop table oc_richdocuments_assets;
  • delete from oc_migrations where app='richdocuments';
  • reinstall the app

@mnheia
Copy link

mnheia commented May 17, 2023

It seems that in my case at least the issue is connected to the Terms of Service app. Version 2.2.0 but I believe that the prior one was also incompatible. Disable app allows documents to load. Enable app break it again.

Possible connected to #771

@joshtrichards joshtrichards added bug Something isn't working needs info labels Nov 10, 2023
@joshtrichards
Copy link
Member

joshtrichards commented Nov 10, 2023

Closing due to #2681 (comment) without any further info provided by original reporter.

Presumed fixed by #2874.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs info
Projects
None yet
Development

No branches or pull requests

6 participants