stefan-niedermann / nextcloud-tables

πŸ“Š Android client for nextcloud tables app
https://play.google.com/store/apps/details?id=it.niedermann.nextcloud.tables.play
GNU General Public License v3.0
29 stars 5 forks source link

Exception is thrown after choosing NC-account #10

Closed germede closed 1 year ago

germede commented 1 year ago

Please use GitHub reactions πŸ‘ to show that you are affected by the same issue. Please don't comment if you have no relevant information to add!

Describe the bug

Steps to reproduce the behavior:

  1. Install the App from F-Droid
  2. Select existing NC-Account from NC-App
  3. Following exception is thrown.

Expected behavior

Tables can be seen and edited.

Screenshots

Versions

Smartphone (please complete the following information):

Stacktrace

App Version: 1.0.7
App Version Code: 1000007
Server App Version: 25.0.0
App Flavor: fdroid

Files App Version Code: 30250090 (PROD)

---

OS Version: 5.4.210-qgki-g20d62d49bc2f(2304282017)
OS API Level: 33
Device: Spacewar
Manufacturer: Nothing
Model (and Product): A063 (SpacewarEEA)

---

com.nextcloud.android.sso.exceptions.NextcloudHttpRequestFailedException: HTTP-Anfrage ist fehlgeschlagen mit HTTP-Statuscode: 520
    at it.niedermann.nextcloud.tables.repository.ServerErrorHandler.handle(ServerErrorHandler.java:53)
    at it.niedermann.nextcloud.tables.repository.ServerErrorHandler.handle(ServerErrorHandler.java:33)
    at it.niedermann.nextcloud.tables.repository.sync.RowSyncAdapter.lambda$pullRemoteChanges$0$it-niedermann-nextcloud-tables-repository-sync-RowSyncAdapter(RowSyncAdapter.java:143)
    at it.niedermann.nextcloud.tables.repository.sync.RowSyncAdapter$$ExternalSyntheticLambda2.run(Unknown Source:10)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:463)
    at java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1137)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:637)
    at java.lang.Thread.run(Thread.java:1012)
Caused by: java.lang.RuntimeException: Could not fetch rows for table with remote ID 1
    ... 9 more
stefan-niedermann commented 1 year ago

Hello @gmedina-de I need some help from you to debug this issue. Are you able to use curl or wget? Or can you alternatively create a test user for me and share the affected table (with ID 1) with me?

germede commented 1 year ago

Hi @stefan-niedermann,

I was actually able to debug and fix it myself as follows:

  1. Had an old, working table in the NC Tables App which has 10 columns or so, but was also modified a lot in the past across different NC tables app versions.
  2. Installed Android Studio and cloned your repo.
  3. Debugged my phone while choosing the Nextcloud account in your app.
  4. Got following internal error when parsing the API response of NC-tables:
    Response{protocol=http/1.1, code=520, message=com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected a string but was BOOLEAN at line 1 column 443 path $[0].data[10].value, url=http://localhost//index.php/apps/tables/api/1/tables/1/rows}
  5. Created another NC test user in the server with a simple new test table: was able to load the test user and the test table in Android without problems.
  6. Running Postman I realised the error causing JSON response: Bildschirmfoto vom 2023-06-25 20-57-39
  7. I reviewed my table in NC-table app and couldn't find any column with id 24.
  8. I decided to run a mysql-client for this Nextcloud instance.
  9. Found out, this column with id 24 didn't exist as well in the oc_tables_columns, but many rows in oc_tables_rows did have this as data.
  10. In order to remove this inconsistent state I decided to run:
    UPDATE oc_tables_rows 
    SET data = replace(data, ', {"value": false, "columnId": 24}', '');
  11. After that the Android App doesn't crash anymore and shows the table nicely.

I don't consider this issue to be related with the Android App itself, so I'll close it as is. Still thank you for the great app and the quick response and have a nice day.

stefan-niedermann commented 1 year ago

Thank you very much for the detailled update! I'll check it later and try finding something reproducible, maybe a migration can be added on the server side.