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

Import fails if table contains null date #18

Closed Thesola10 closed 6 months ago

Thesola10 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

I have a Nextcloud table with an optional date column, meaning some rows have no date. When importing my account onto the app, it fails with an error and kicks me back to the login screen.

Steps to reproduce the behavior:

  1. On Nextcloud Web, create a table with an optional date/time column
  2. Create a row without setting the date/time value
  3. Import the Nextcloud account into the app

Expected behavior

Table is imported without issue and I can proceed to the main app UI

Screenshots

Versions

Smartphone (please complete the following information):

Stacktrace

java.time.format.DateTimeParseException: Text 'none' could not be parsed at index 0
    at java.time.format.DateTimeFormatter.parseResolved0(DateTimeFormatter.java:1949)
    at java.time.format.DateTimeFormatter.parse(DateTimeFormatter.java:1777)
    at it.niedermann.nextcloud.tables.remote.adapter.DataAdapter.deserialize(DataAdapter.java:114)
    at it.niedermann.nextcloud.tables.repository.sync.RowSyncAdapter.lambda$pullRemoteChanges$0$it-niedermann-nextcloud-tables-repository-sync-RowSyncAdapter(RowSyncAdapter.java:176)
    at it.niedermann.nextcloud.tables.repository.sync.RowSyncAdapter$$ExternalSyntheticLambda2.run(Unknown Source:10)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:462)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
    at java.lang.Thread.run(Thread.java:920)
stefan-niedermann commented 1 year ago

Hmm, I have troubles reproducing this issue. I tried to follow your steps to reproduce, creating a new table with one optional datetime column without default value. Then i created one row. As value I can't see none but the value ain't present at all, so the behavior is different to yours.

Are you familiar using curl or wget? If yes, it would be incredibly helpful to type this command into a terminal (the TABLE_ID can be found in the url) and show me the output (remove sensitive private data though!).

curl "https://USERNAME:PASSWORD@EXAMPLE.COM/index.php/apps/tables/api/1/tables/TABLE_ID/rows?format=json" -H 'OCS-APIRequest: true'

I currently suspect that you created your table, column or row with a previous tables server (or Android) version which did behave different. In this case we need to report this as issue to the Tables server app so they can add a migration script with the next update or we need to fix this in the Tables Android app.

Thesola10 commented 1 year ago

ttt.json.txt

The API does indeed return "none" for empty date rows on my JSON readout. Did you try reproducing the bug on Nextcloud 26.0.4 with Tables 0.5.1? Couldn't your app sanitize none date fields on the basis that not everyone is likely to use the latest Nextcloud with the app?

If at all relevant, I'm running PHP 8.2.7 and Nextcloud as provided by NixOS 23.05

denisyak1 commented 9 months ago

Hi, I experience this now. I recently started at table with an optional date column and the app crashes with the following error message (I'm on beta version) unless I populate all dates. Unfortunately the log is trimmed (last 3 lines were dropped)

App Version: 1.1.2
App Version Code: 1001002
Server App Version: 27.1.0
App Flavor: play

Files App Version Code: 30260090 (PROD)

---

OS Version: 5.10.160-android12-9-00011-gee9c5aba8693-ab10241288(47466-054c2)
OS API Level: 33
Device: hiphic
Manufacturer: motorola
Model (and Product): XT2201-2 (hiphic_cn)

---

java.util.concurrent.CompletionException: java.time.format.DateTimeParseException: Text 'none' could not be parsed at index 0
    at it.niedermann.nextcloud.tables.ui.table.view.ViewTableViewModel.lambda$synchronizeAccountAndTables$0$it-niedermann-nextcloud-tables-ui-table-view-ViewTableViewModel(ViewTableViewModel.java:50)
    at it.niedermann.nextcloud.tables.ui.table.view.ViewTableViewModel$$ExternalSyntheticLambda1.get(Unknown Source:4)
    at java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1676)
    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.time.format.DateTimeParseException: Text 'none' could not be parsed at index 0
    at java.time.format.DateTimeFormatter.parseResolved0(DateTimeFormatter.java:2044)
    at java.time.format.DateTimeFormatter.parse(DateTimeFormatter.java:1872)
    at it.niedermann.nextcloud.tables.remote.adapter.DataAdapter.deserialize(DataAdapter.java:116)
    at it.niedermann.nextcloud.tables.repository.sync.RowSyncAdapter.lambda$pullRemoteChanges$0$it-niedermann-nextcloud-tables-repository-sync-RowSyncAdapter(RowSyncAdapter.java:176)
    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)
    ... 3 more
stefan-niedermann commented 6 months ago

Fix will be published with 1.1.3