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

App has failed to run initial sync due to 403 (issue started occurring long ago) #1560

Open
3 of 4 tasks
xarinatan opened this issue Jan 6, 2024 · 25 comments
Open
3 of 4 tasks

Comments

@xarinatan
Copy link

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
When running the initial sync, after a fresh install from either the Fdroid store on my FOSS phone, or the Play store on my stock Pixel, the application crashes with a whole load of errors. The initial error seems to be related to a 403, but I can't really tell why:

App Version: 1.23.4
App Version Code: 1023004
Server App Version: 1.11.2
App Flavor: fdroid

Files App Version Code: 30260090 (PROD)
Files App Version Code: 20231230 (DEV)

---

OS Version: 4.14.180-perf+(2f0ec645e3)
OS API Level: 33
Device: OnePlus7Pro
Manufacturer: OnePlus
Model (and Product): GM1911 (OnePlus7Pro)

---

com.nextcloud.android.sso.exceptions.NextcloudHttpRequestFailedException: HTTP request failed with HTTP status-code: 403
	at com.nextcloud.android.sso.api.AidlNetworkRequest.performNetworkRequestV2(AidlNetworkRequest.java:197)
	at com.nextcloud.android.sso.api.NextcloudAPI.performNetworkRequestV2(NextcloudAPI.java:180)
	at com.nextcloud.android.sso.api.NextcloudAPI.lambda$performRequestObservableV2$0$com-nextcloud-android-sso-api-NextcloudAPI(NextcloudAPI.java:122)
	at com.nextcloud.android.sso.api.NextcloudAPI$$ExternalSyntheticLambda0.subscribe(Unknown Source:6)
	at io.reactivex.internal.operators.observable.ObservableFromPublisher.subscribeActual(ObservableFromPublisher.java:31)
	at io.reactivex.Observable.subscribe(Observable.java:12284)
	at io.reactivex.internal.operators.observable.ObservableMap.subscribeActual(ObservableMap.java:32)
	at io.reactivex.Observable.subscribe(Observable.java:12284)
	at io.reactivex.internal.operators.observable.ObservableSubscribeOn$SubscribeTask.run(ObservableSubscribeOn.java:96)
	at io.reactivex.internal.schedulers.ScheduledDirectTask.call(ScheduledDirectTask.java:38)
	at io.reactivex.internal.schedulers.ScheduledDirectTask.call(ScheduledDirectTask.java:26)
	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.IllegalStateException: {"status":403,"message":"Permission denied"}

	at com.nextcloud.android.sso.InputStreamBinder.processRequestV2(InputStreamBinder.java:454)
	at com.nextcloud.android.sso.InputStreamBinder.performNextcloudRequestAndBodyStreamV2(InputStreamBinder.java:127)
	at com.nextcloud.android.sso.InputStreamBinder.performNextcloudRequestV2(InputStreamBinder.java:110)
	at com.nextcloud.android.sso.aidl.IInputStreamService$Stub.onTransact(IInputStreamService.java:110)
	at android.os.Binder.execTransactInternal(Binder.java:1280)
	at android.os.Binder.execTransact(Binder.java:1244)

After the above crash, it spams various other errors, including SQLite Constraints errors, and illegal state exceptions:

Full Crash:

App Version: 1.23.4
App Version Code: 1023004
App Flavor: fdroid

Files App Version Code: 30260090 (PROD)
Files App Version Code: 20231230 (DEV)

---

OS Version: 4.14.180-perf+(2f0ec645e3)
OS API Level: 33
Device: OnePlus7Pro
Manufacturer: OnePlus
Model (and Product): GM1911 (OnePlus7Pro)

---

java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState
	at androidx.fragment.app.FragmentManager.checkStateLoss(FragmentManager.java:1632)
	at androidx.fragment.app.FragmentManager.enqueueAction(FragmentManager.java:1672)
	at androidx.fragment.app.BackStackRecord.commitInternal(BackStackRecord.java:341)
	at androidx.fragment.app.BackStackRecord.commit(BackStackRecord.java:306)
	at androidx.fragment.app.DialogFragment.show(DialogFragment.java:507)
	at it.niedermann.nextcloud.deck.ui.ImportAccountActivity$1$1$1$1$1.lambda$onError$0$it-niedermann-nextcloud-deck-ui-ImportAccountActivity$1$1$1$1$1(ImportAccountActivity.java:162)
	at it.niedermann.nextcloud.deck.ui.ImportAccountActivity$1$1$1$1$1$$ExternalSyntheticLambda0.run(Unknown Source:6)
	at android.os.Handler.handleCallback(Handler.java:942)
	at android.os.Handler.dispatchMessage(Handler.java:99)
	at android.os.Looper.loopOnce(Looper.java:201)
	at android.os.Looper.loop(Looper.java:288)
	at android.app.ActivityThread.main(ActivityThread.java:7924)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)

Steps to reproduce the behavior:

  1. Install app on any device
  2. Select my main account from either the Nextcloud or Nextcloud Dev app
  3. Sync starts, avatar appears, says "syncing 1 of 19 boards.."
  4. Crash above happens, followed by a whole lot of other errors probably due to the failed initial request

Expected behavior
Logging in, seeing my boards, being able to use the app.

Screenshots
Here's a screen recording of it happening: https://nextcloud.dragonhive.net/s/QjB6PBgGm5MqLXT (had to upload to my own Nextcloud because Github doesn't accept more than 10MB)

Versions

Unfortunately I don't know the exact version where this started happening, but it's been a problem for somewhere around half a year to a year. I always keep my Nextcloud Server and the applications running on it religiously up to date with automated means, so it's hard to track when it really started.

Smartphone (please complete the following information):

  • Device: OnePlus 7 Pro (FOSS) Pixel 7 Pro (Stock)
  • Android-Version: 13
  • App-Store:
    • Google Play Store
    • Google Play Store (Beta channel)
    • F-Droid
    • Huawei AppGallery

additional notes and thoughts
My Nextcloud server/account uses 2FA, maybe that's related? though it used to work in the past.
The app was really nice when it worked, I'd be happy to try specific things to debug the issue if you want me to test things.

@xarinatan
Copy link
Author

xarinatan commented Jan 8, 2024

I noticed that when I try to connect with Deck using the app, the server logs this error:

{"reqId":"aLbVml1E6DfFz8GeNzwV","level":3,"time":"2024-01-08T20:37:52+00:00","remoteAddr":"82.101.240.101","user":"--","app":"index","method":"GET","url":"/index.php/apps/deck/api/v1.1/boards/9/stacks/30/cards/263?","message":"userId must be provided and must be not empty","userAgent":"Mozilla/5.0 (Android) Nextcloud-android/3.26.0","version":"28.0.1.1","exception":{"Exception":"OCA\\Deck\\BadRequestException","Message":"userId must be provided and must be not empty","Code":0,"Trace":[{"file":"/var/www/html/custom_apps/deck/lib/Validators/BaseValidator.php","line":85,"function":"validate","class":"OCA\\Deck\\Validators\\BaseValidator","type":"->","args":[[null]]},{"file":"/var/www/html/custom_apps/deck/lib/Service/AssignmentService.php","line":108,"function":"check","class":"OCA\\Deck\\Validators\\BaseValidator","type":"->","args":[[null]]},{"function":"__construct","class":"OCA\\Deck\\Service\\AssignmentService","type":"->","args":[["OCA\\Deck\\Service\\PermissionService"],["OCA\\Deck\\Db\\CardMapper"],["OCA\\Deck\\Db\\AssignmentMapper"],["OCA\\Deck\\Db\\AclMapper"],["OCA\\Deck\\Notification\\NotificationHelper"],["OCA\\Deck\\Activity\\ActivityManager"],["OCA\\Deck\\Db\\ChangeHelper"],["OC\\EventDispatcher\\EventDispatcher"],["OCA\\Deck\\Validators\\AssignmentServiceValidator"],null]},{"file":"/var/www/html/lib/private/AppFramework/Utility/SimpleContainer.php","line":83,"function":"newInstanceArgs","class":"ReflectionClass","type":"->","args":[[["OCA\\Deck\\Service\\PermissionService"],["OCA\\Deck\\Db\\CardMapper"],["OCA\\Deck\\Db\\AssignmentMapper"],["OCA\\Deck\\Db\\AclMapper"],["OCA\\Deck\\Notification\\NotificationHelper"],["OCA\\Deck\\Activity\\ActivityManager"],["OCA\\Deck\\Db\\ChangeHelper"],["OC\\EventDispatcher\\EventDispatcher"],["OCA\\Deck\\Validators\\AssignmentServiceValidator"],null]]},{"file":"/var/www/html/lib/private/AppFramework/Utility/SimpleContainer.php","line":128,"function":"buildClass","class":"OC\\AppFramework\\Utility\\SimpleContainer","type":"->","args":[["ReflectionClass","OCA\\Deck\\Service\\AssignmentService"]]},{"file":"/var/www/html/lib/private/AppFramework/Utility/SimpleContainer.php","line":146,"function":"resolve","class":"OC\\AppFramework\\Utility\\SimpleContainer","type":"->","args":["OCA\\Deck\\Service\\AssignmentService"]},{"file":"/var/www/html/lib/private/AppFramework/DependencyInjection/DIContainer.php","line":468,"function":"query","class":"OC\\AppFramework\\Utility\\SimpleContainer","type":"->","args":["OCA\\Deck\\Service\\AssignmentService"]},{"file":"/var/www/html/lib/private/AppFramework/DependencyInjection/DIContainer.php","line":440,"function":"queryNoFallback","class":"OC\\AppFramework\\DependencyInjection\\DIContainer","type":"->","args":["OCA\\Deck\\Service\\AssignmentService"]},{"file":"/var/www/html/lib/private/AppFramework/Utility/SimpleContainer.php","line":96,"function":"query","class":"OC\\AppFramework\\DependencyInjection\\DIContainer","type":"->","args":["OCA\\Deck\\Service\\AssignmentService",true]},{"function":"OC\\AppFramework\\Utility\\{closure}","class":"OC\\AppFramework\\Utility\\SimpleContainer","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/html/lib/private/AppFramework/Utility/SimpleContainer.php","line":83,"function":"array_map","args":[["Closure"],[["ReflectionParameter","appName"],["ReflectionParameter","request"],["ReflectionParameter","cardService"],"*** sensitive parameters replaced ***",["ReflectionParameter","userId"]]]},{"file":"/var/www/html/lib/private/AppFramework/Utility/SimpleContainer.php","line":128,"function":"buildClass","class":"OC\\AppFramework\\Utility\\SimpleContainer","type":"->","args":[["ReflectionClass","OCA\\Deck\\Controller\\CardApiController"]]},{"file":"/var/www/html/lib/private/AppFramework/Utility/SimpleContainer.php","line":146,"function":"resolve","class":"OC\\AppFramework\\Utility\\SimpleContainer","type":"->","args":["OCA\\Deck\\Controller\\CardApiController"]},{"file":"/var/www/html/lib/private/AppFramework/DependencyInjection/DIContainer.php","line":468,"function":"query","class":"OC\\AppFramework\\Utility\\SimpleContainer","type":"->","args":["OCA\\Deck\\Controller\\CardApiController"]},{"file":"/var/www/html/lib/private/AppFramework/DependencyInjection/DIContainer.php","line":440,"function":"queryNoFallback","class":"OC\\AppFramework\\DependencyInjection\\DIContainer","type":"->","args":["OCA\\Deck\\Controller\\CardApiController"]},{"file":"/var/www/html/lib/private/AppFramework/App.php","line":163,"function":"query","class":"OC\\AppFramework\\DependencyInjection\\DIContainer","type":"->","args":["OCA\\Deck\\Controller\\CardApiController"]},{"file":"/var/www/html/lib/private/Route/Router.php","line":315,"function":"main","class":"OC\\AppFramework\\App","type":"::","args":["OCA\\Deck\\Controller\\CardApiController","get",["OC\\AppFramework\\DependencyInjection\\DIContainer"],["1.1","9","30","263","deck.card_api.get"]]},{"file":"/var/www/html/lib/base.php","line":1069,"function":"match","class":"OC\\Route\\Router","type":"->","args":["/apps/deck/api/v1.1/boards/9/stacks/30/cards/263"]},{"file":"/var/www/html/index.php","line":39,"function":"handleRequest","class":"OC","type":"::","args":[]}],"File":"/var/www/html/custom_apps/deck/lib/Validators/BaseValidator.php","Line":66,"message":"userId must be provided and must be not empty","exception":{},"CustomMessage":"userId must be provided and must be not empty"}}

The userId must be provided and must be not empty part seems to imply some user variable that is required isn't getting passed along with the request I think? but it's hard to tell what really happens underneath

@desperateCoder
Copy link
Collaborator

@xarinatan Hi!

Can you please try if this dev build performs any better?

(ノ◕ヮ◕)ノ*:・゚✧ APK

This APK will install along with your current version. In your app drawer you'll find two deck apps, while the one above will have a "DEV" label on its icon.

Please report back if you still run into issues with this version.

@xarinatan
Copy link
Author

@desperateCoder Thanks for the dev build! I appreciate you taking the time. It appears to have gotten a little further, but after board 3 out of 19 it crashed with the same 403 SSO error again:

App Version: 1.23.4
App Version Code: 1023004
Server App Version: 1.12.0
App Flavor: dev

Files App Version Code: 30260090 (PROD)
Files App Version Code: 20240106 (DEV)

---

OS Version: 4.14.180-perf+(9a5a210895)
OS API Level: 33
Device: OnePlus7Pro
Manufacturer: OnePlus
Model (and Product): GM1911 (OnePlus7Pro)

---

com.nextcloud.android.sso.exceptions.NextcloudHttpRequestFailedException: HTTP request failed with HTTP status-code: 500
	at it.niedermann.nextcloud.deck.remote.api.RequestHelper$ResponseConsumer.onResponse(RequestHelper.java:51)
	at com.nextcloud.android.sso.helper.Retrofit2Helper$1.lambda$enqueue$0$com-nextcloud-android-sso-helper-Retrofit2Helper$1(Retrofit2Helper.java:86)
	at com.nextcloud.android.sso.helper.Retrofit2Helper$1$$ExternalSyntheticLambda0.run(Unknown Source:6)
	at java.lang.Thread.run(Thread.java:1012)
Caused by: java.lang.RuntimeException: HTTP StatusCode wasn't 2xx:
Got [HTTP 500] for Call [GET http://localhost//index.php/apps/deck/api/v1.1/boards/3/stacks/36/cards/193] with Message:
[<!DOCTYPE html>
[snipped the error page html out]
]
	at it.niedermann.nextcloud.deck.remote.api.RequestHelper$ResponseConsumer.buildCause(RequestHelper.java:68)
	... 4 more

also serverside it shows the same userid error:
image

let me know if I can do anything else! I'm also the server admin so I can access any logs from either point of view (also the raw logs on the server itself)

@xarinatan
Copy link
Author

xarinatan commented Jan 11, 2024

actually there are several different clientside errors, the above one is a 500 variety (but generates that error on the serverside)

find it hard to currently reproduce the 403, but I think it may just be one of the other errors that appear at the same time on the client.

here's a 303 variety (http "See Other" redirect)

App Version: 1.23.4
App Version Code: 1023004
Server App Version: 1.12.0
App Flavor: dev

Files App Version Code: 30260090 (PROD)
Files App Version Code: 20240106 (DEV)

---

OS Version: 4.14.180-perf+(9a5a210895)
OS API Level: 33
Device: OnePlus7Pro
Manufacturer: OnePlus
Model (and Product): GM1911 (OnePlus7Pro)

---

com.nextcloud.android.sso.exceptions.NextcloudHttpRequestFailedException: HTTP request failed with HTTP status-code: 303
	at it.niedermann.nextcloud.deck.remote.api.RequestHelper$ResponseConsumer.onResponse(RequestHelper.java:51)
	at com.nextcloud.android.sso.helper.Retrofit2Helper$1.lambda$enqueue$0$com-nextcloud-android-sso-helper-Retrofit2Helper$1(Retrofit2Helper.java:86)
	at com.nextcloud.android.sso.helper.Retrofit2Helper$1$$ExternalSyntheticLambda0.run(Unknown Source:6)
	at java.lang.Thread.run(Thread.java:1012)
Caused by: java.lang.RuntimeException: HTTP StatusCode wasn't 2xx:
Got [HTTP 303] for Call [GET http://localhost//ocs/v2.php/apps/deck/api/v1.0/cards/53/comments] with Message:
[]
	at it.niedermann.nextcloud.deck.remote.api.RequestHelper$ResponseConsumer.buildCause(RequestHelper.java:68)
	... 4 more

@desperateCoder
Copy link
Collaborator

@xarinatan

the server logs this error:

I just checked on this, I have strong indications that the server is having a bug here... I'll dig a little more, since you're not the only one experiencing this. (see #1447 (comment))

@kotnik
Copy link

kotnik commented Feb 9, 2024

I have been affected by this issue for a long time as well. And I think I might have some insight.

What I noticed is that server 403s or 500s on specific boards, for example:

app_1  | <IP SNIP> - kotnik [09/Feb/2024:10:15:05 +0000] "GET /index.php/apps/deck/api/v1.0/boards/1/stacks HTTP/1.1" 403 3010 "-" "Mozilla/5.0 (Android) Nextcloud-android/3.27.0"

But, that board is deleted, I don't even see it in Nextcloud's UI! So, I checked, and yes, Nextcloud is listing it the list of the boards, but pay attention, it has deleted_at set:

❯ $CURL_CMD/boards | jq                                                                                                                                        
[                                 
  {                                  
    "id": 1,                           
    "title": "Personal",          
    "owner": {              
      "primaryKey": "kotnik",          
      "uid": "kotnik",                                                                                                                                         
      "displayname": "Nikola",                                                                                                                                 
      "type": 0                                                                                                                                                
    },                                                                                                                                                         
    "color": "0087C5",                                                         
    "archived": true,                                                                                                                                          
    "labels": [],                                                                                                                                              
    "acl": [],                                                                                                                                                 
    "permissions": {                  
      "PERMISSION_READ": true,                                                                                                                                 
      "PERMISSION_EDIT": true,                                                                                                                                 
      "PERMISSION_MANAGE": true,                                                                                                                               
      "PERMISSION_SHARE": true         
    },                                                                         
    "users": [],                                                                                                                                               
    "shared": 0,                       
    "stacks": [],                                                                                                                                              
    "activeSessions": [],                                                      
    "deletedAt": 1707473904,                                                   
    "lastModified": 1707473904,                                                                                                                                
    "settings": [],                                                                                                                                            
    "ETag": "08bbff6e4858f9151eabe31ad9904747"                                                                                                                 
  },              

And true, if I try it myself, I get 403 too:

❯ $CURL_CMD/boards/1/stacks
{"status":403,"message":"Permission denied"}

So, I think, if you simply delete a board and then try to do clean sync you will easily reproduce this issue. And also, to ignore deleted boards would solve this issue.

@desperateCoder
Copy link
Collaborator

Hi @kotnik, that's actually an awesome hint, thanks! I'll try it as soon as I get to find some free time!

@kotnik
Copy link

kotnik commented Feb 9, 2024

Possibly related: nextcloud/deck#2198

@desperateCoder
Copy link
Collaborator

@kotnik I hacked a filter for deleted boards in a quick-and-dirty manner, so we can test if this fixes anything for you. Lets see...

Can you please try the following DEV-build:

༼つಠ益ಠ༽つ ─=≡ΣO)) APK

It will install beside your actual deck app. It'll have a "DEV" label on the app icon. Please use this version, connect it to your account and tell me, if it manages to sync properly. If it does, you sir, deserve a damn medal.

@xarinatan
Copy link
Author

@desperateCoder I figured I'd also give this a try, but unfortunately I'm getting a Java crash due to referencing an interface/method it can't find:

Full Crash:

App Version: 1.23.4
App Version Code: 1023004
App Flavor: dev

Files App Version Code: 30270090 (PROD)

---

OS Version: 4.14.180-perf+(dfff6cd121)
OS API Level: 33
Device: OnePlus7Pro
Manufacturer: OnePlus
Model (and Product): GM1911 (OnePlus7Pro)

---

java.lang.NoSuchMethodError: No interface method toList()Ljava/util/List; in class Ljava/util/stream/Stream; or its super classes (declaration of 'java.util.stream.Stream' appears in /apex/com.android.art/javalib/core-oj.jar)
	at it.niedermann.nextcloud.deck.remote.helpers.providers.BoardDataProvider$1.onResponse(BoardDataProvider.java:74)
	at it.niedermann.nextcloud.deck.remote.helpers.providers.BoardDataProvider$1.onResponse(BoardDataProvider.java:60)
	at it.niedermann.nextcloud.deck.remote.api.RequestHelper$ResponseConsumer.onResponse(RequestHelper.java:68)
	at com.nextcloud.android.sso.helper.Retrofit2Helper$1.lambda$enqueue$0(Retrofit2Helper.java:87)
	at com.nextcloud.android.sso.helper.Retrofit2Helper$1.$r8$lambda$n0izO5V3AflskH7z1H8dSLmVKXo(Unknown Source:0)
	at com.nextcloud.android.sso.helper.Retrofit2Helper$1$$ExternalSyntheticLambda0.run(Unknown Source:6)
	at java.lang.Thread.run(Thread.java:1012)

@desperateCoder
Copy link
Collaborator

@xarinatan thanks for testing!

Gosh, apparently Android doesn't like javas stream-feature. Ok, lets do it the classic way then, here you go:

(ᕗ ͠° ਊ ͠° )ᕗ APK

@xarinatan
Copy link
Author

xarinatan commented Feb 10, 2024

@desperateCoder

it didn't crash on java, and it got all the way to the 4th board before crashing with another 503, but only one this time before it halted (no error spam like in the initial case):

App Version: 1.23.4
App Version Code: 1023004
Server App Version: 1.12.1
App Flavor: dev

Files App Version Code: 30270090 (PROD)

---

OS Version: 4.14.180-perf+(dfff6cd121)
OS API Level: 33
Device: OnePlus7Pro
Manufacturer: OnePlus
Model (and Product): GM1911 (OnePlus7Pro)

---

com.nextcloud.android.sso.exceptions.NextcloudHttpRequestFailedException: HTTP request failed with HTTP status-code: 500
	at it.niedermann.nextcloud.deck.remote.api.RequestHelper$ResponseConsumer.onResponse(RequestHelper.java:70)
	at com.nextcloud.android.sso.helper.Retrofit2Helper$1.lambda$enqueue$0(Retrofit2Helper.java:87)
	at com.nextcloud.android.sso.helper.Retrofit2Helper$1.$r8$lambda$n0izO5V3AflskH7z1H8dSLmVKXo(Unknown Source:0)
	at com.nextcloud.android.sso.helper.Retrofit2Helper$1$$ExternalSyntheticLambda0.run(Unknown Source:6)
	at java.lang.Thread.run(Thread.java:1012)
Caused by: java.lang.RuntimeException: HTTP StatusCode wasn't 2xx:
Got [HTTP 500] for Call [GET http://localhost//index.php/apps/deck/api/v1.1/boards/5/stacks/14/cards/22] with Message:
[<!DOCTYPE html>---- snipped HTML error page out --- 
]
	at it.niedermann.nextcloud.deck.remote.api.RequestHelper$ResponseConsumer.buildCause(RequestHelper.java:87)
	... 5 more

I fetched the mentioned card with the curl request from the other bug, it doesn't appear the specific card is deleted or causes errors when fetching the contents with the curl request though:

{"id":22,"title":"Twingo Tuning guide","description":"\nI thought I would write this up ---snipped content away to avoid spam---","stackId":14,"type":"plain","lastModified":1641846765,"lastEditor":null,"createdAt":1641846759,"labels":[],"assignedUsers":[],"attachments":[],"attachmentCount":0,"owner":{"primaryKey":"alexanderypema@gmail.com","uid":"alex* Connection #0 to host nextcloud.dragonhive.net left intact
anderypema@gmail.com","displayname":"Anthropy","type":0},"order":999,"archived":false,"done":null,"duedate":null,"deletedAt":0,"commentsUnread":0,"commentsCount":0,"ETag":"33ff3b8fbeedd3d6ef848af11a24a6b5","overdue":0}

@desperateCoder
Copy link
Collaborator

@xarinatan thanks for testing again!

At least we're not getting 403, thats what the fix was supposed to fix. So your server is telling us that its fine when you do it via curl, but not if the app does the exact same request? I really suspect a backend side problem here... Weird

Let's see if it changes something for @kotnik.

@xarinatan
Copy link
Author

xarinatan commented Feb 10, 2024

@desperateCoder Thanks for providing the debug builds! I'm happy to try to help resolve this issue and do further debugging.

honestly initially there were a whole bunch of errors so I just picked the one I managed to copy, but it wasn't consistent, sometimes 5xx, sometimes 4xx (like the 403 mentioned), sometimes even 3xx, but it's definitely gotten less random with these more recent debug builds, and I do suspect that filtering out deleted cards is part of the issue!

As for the backend, I don't think I have anything weird installed honestly, and my server is running a full ECC memory/CPU stack and checksumming storage that should let me know if there are any hardware issues happening, plus I always keep up to date with the latest Nextcloud (currently 28.0.2)..

Checking the serverside logs there are a few items that stand out to me:

  • It's hard to pinpoint exactly where these are coming from since it says 'no app in context', but I see a few instances of Session token invalidated before logout when running the Nextcloud Deck app, as well as Logging out.
  • It also got me thinking whether the (official and by my knowledge working) encryption plugin may be interfering in some way, although that one is spamming debug messages constantly regardless of Nextcloud Deck running.
  • I also still see the BadRequestException userId must be provided and must be not empty error occuring when the Nextcloud Deck app is run, which I suspect is the cause for the 503, as that one is logged as an actual Error in the Index application

Let me know if I can try anything else, I would really love to be able to use the honestly excellent application again some day :) I much share the frustration of this bug being so pervasive and hard to root cause.

I also hope it gets fixed for @kotnik specifically , if so that would be a big step forward.

@xarinatan
Copy link
Author

xarinatan commented Feb 10, 2024

did some further testing with the debug apk, I found these results interesting:

  • The debug APK sometimes it fails with connection rejected, even though my server is definitely up, and running a ping for a while does not reveal dropped packets
  • When it fails with 'connection rejected' it could already be on the third board, although sometimes it does it right at the start
  • often with the connection rejected error, it throws a whole stack of them at once, and I have to close 10+ errors to get back to the app
  • The card it mentions in the 5xx error is different each time, but usually a rather old one that's been sitting there for at least 8 months (could just be I have a lot of older cards though).
  • Some of the cards it errors on have no 'activity' when opened from the official Nextcloud Deck web app
  • With every 5xx crash (other than the connection failures and full app crashes) the server always logs BadRequestException userId must be provided and must be not empty as far as I can tell
  • sometimes the debug APK crashes entirely with other errors, such as:
Full Crash:

App Version: 1.23.4
App Version Code: 1023004
App Flavor: dev

Files App Version Code: 30270090 (PROD)

---

OS Version: 4.14.180-perf+(dfff6cd121)
OS API Level: 33
Device: OnePlus7Pro
Manufacturer: OnePlus
Model (and Product): GM1911 (OnePlus7Pro)

---

java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Long it.niedermann.nextcloud.deck.model.Card.getLocalId()' on a null object reference
	at it.niedermann.nextcloud.deck.remote.helpers.providers.CardUserRelationshipProvider.deleteAllExisting(CardUserRelationshipProvider.java:38)
	at it.niedermann.nextcloud.deck.remote.helpers.SyncHelper.fixRelations(SyncHelper.java:225)
	at it.niedermann.nextcloud.deck.remote.helpers.providers.CardDataProvider.goDeeper(CardDataProvider.java:164)
	at it.niedermann.nextcloud.deck.remote.helpers.providers.CardDataProvider.goDeeper(CardDataProvider.java:39)
	at it.niedermann.nextcloud.deck.remote.helpers.SyncHelper$1.onResponse(SyncHelper.java:98)
	at it.niedermann.nextcloud.deck.remote.helpers.SyncHelper$1.onResponse(SyncHelper.java:57)
	at it.niedermann.nextcloud.deck.remote.helpers.providers.CardDataProvider$1.onResponse(CardDataProvider.java:81)
	at it.niedermann.nextcloud.deck.remote.helpers.providers.CardDataProvider$1.onResponse(CardDataProvider.java:76)
	at it.niedermann.nextcloud.deck.remote.api.RequestHelper$ResponseConsumer.onResponse(RequestHelper.java:68)
	at com.nextcloud.android.sso.helper.Retrofit2Helper$1.lambda$enqueue$0(Retrofit2Helper.java:87)
	at com.nextcloud.android.sso.helper.Retrofit2Helper$1.$r8$lambda$n0izO5V3AflskH7z1H8dSLmVKXo(Unknown Source:0)
	at com.nextcloud.android.sso.helper.Retrofit2Helper$1$$ExternalSyntheticLambda0.run(Unknown Source:6)
	at java.lang.Thread.run(Thread.java:1012)

  • I still occasionally get a large storm of errors, some of which being 403, and sometimes the application crashes in different ways giving different types of dialogues and throwing me back to the android app drawer/homescreen.. It feels a bit like the app is trying to spawn a lot of concurrent connections, one or more for each board, which may also be causing the connection rejected errors perhaps, and I'm also wondering if it could be causing other values to be null or otherwise unexpected states due to the parallelization, is there any way to turn the multithreading off? I don't really care if the initial sync takes an hour or more, if it works at all then that's infinitely better than a very quick crash for me ;P
  • the fact the curl requests work, the web app works, and the randomness of the errors really does make me suspect the issue is still with the app and not the server; as far as I can tell the server is operating normally, there are various other services running on it without a hitch, including Nextcloud, Seafile, Gitlab, Matrix, Mastodon, etc. It is purely this specific application that is having trouble, as much as I agree that it's a very frustrating and hard to diagnose issue. I'm happy to run any specific debug applications or curl requests or other custom bits of code to try and diagnose the issue, because I do very much like the application, and don't want to imply anything negative about the app or the creators beyond the errors that I'm having ❤️

@desperateCoder
Copy link
Collaborator

@xarinatan thanks for your research!

  • regarding connection rejected: this could be related to apache's max connection limit. Could you check what value is set on your installation? And yes, in many cases a single failed request rips down the whole house of cards and you're flooded with weird errors of subsequent actions.
  • regarding userId must be provided and must be not empty: we already had that hint, here's what the server-side dev said to this: SQLiteConstraintException: UNIQUE constraint failed #1447 (comment) (in short: weird, but no idea why this seems to happen)
  • regarding the full crash: seems to be a follow up to a previous error, although I'm not sure why the code proceeds to this point at all. Concurrency is hell, but without concurrency the app would feel very shitty, so I need to make it just work (its getting kind of personal here 😅 )
  • regarding " spawn a lot of concurrent connections": yep. thats basically how it works. The amount of connections is limited by the number of CPU cores though. The app looks at your CPU and decides the thread pool size based of the number of cores it has, so there's minimum context switching for the process while using up the resources in the most efficient way it can. Sure, I could limit the thread pool to a number close to 1, I think this is worth a try. When I find some time, I'll build a version with a smaller thread pool size for you.
  • I can't really deny that the app might be the weak point here, at least not for sure. The problem is the insane amount of fragmentation of the ecosystem. There are so many different setups out there. Regarding webhosters, container-setups, even android versions, hardware on both (server and client) sides, Versions of nextcloud, the combination of them with specific deck server app versions and so on. I think you get the point. You might be right, but for now I just cant tell. I'm digging arount regarding these sync issues for a while now, and yes, its damn frustrating. But as I stated: Its getting personal to me and I refuse to give up on this. The problem here is just, that I do this in my free time and life won't always let me having time to debug 12 threads simultanously... Its really helpful to have users like you, who are willing to help to resolve such issues, thanks for that! Plus: no offense taken! I'm not happy with the current situation either, so i fully understand what you're saying!

For now, if you could check on the max-connections of your apache, that would help to complete the image a little more. As soon as I find time to play around with the thread pool size, I'll post an APK for you.

Thanks for your help!

@desperateCoder
Copy link
Collaborator

@xarinatan ok, here's a version with a core pool size of 1, while it will grow to 2 when it hat much to do. Imho this should be low enough.

Here you go, lets see if it changes anything. I'd bet it doesn't 😓

ʕノ•ᴥ•ʔノ ︵ ┻━┻

@xarinatan
Copy link
Author

@desperateCoder Thank you for the kind words, and the new debug build! I'll be sure to test it.

I'm struggling to get past the 'connection rejected' part now for some reason even with this new debug build. It should be noted that I'm using nginx and it should allow for 512 connections per worker, which I'd say is plenty for something like this.. and if I check the frontend loadbalancer's logs, I can't see anything weird there either, only a few requests happen at the same time, and the requests actually seem to be met with 2xx responses, at least for nextcloud's subdomain. I'll try to dig a bit more into it, will let you know if I figure it out.

@desperateCoder
Copy link
Collaborator

@xarinatan thanks for the feedback! just note that your nginx (i assume you're using it as a reverse proxy?) might not be the bottleneck here. Nextcloud is PHP based and most likely runs on an apache webserver. if your apache is configured to eg. 5 connections only (bullshit number obviously), your nginx can allow as many as it wants, the apache still won't. After the connection is rejected by apache, its a implementation detail of the proxy deciding what kind of response the client actually gets.

But yeah, take your time analyzing what is actually happening there, we get closer and closer, although we don't know the missing distance yet 😅

@kotnik
Copy link

kotnik commented Feb 12, 2024

@desperateCoder I just tried the latest APK you posted, and success! The boards load and I can use them.

It's been a while since I saw them on my phone 😊

@desperateCoder
Copy link
Collaborator

@kotnik awesome! Congratulations for "fixing" it all by yourself, and big thanks again for your hint!

Could you please test the version of following comment as well? #1560 (comment)

I just want to make sure the connection pooling isn't the problem here. If this works, I'll use the fix for the next upcoming version, since it doesn't seem to break anything and fixes a good portion of the problem.

@kotnik
Copy link

kotnik commented Feb 14, 2024

Just tried that one as well. At first run it failed with:

Full Crash:

App Version: 1.23.4
App Version Code: 1023004
App Flavor: dev

Files App Version Code: 30270090 (PROD)

---

OS Version: 5.10.177-android13-4-00003-ga7208022a7ea-ab10815828(11129216)
OS API Level: 34
Device: raven
Manufacturer: Google
Model (and Product): Pixel 6 Pro (raven)

---

java.lang.NullPointerException: Attempt to invoke virtual method 'void it.niedermann.nextcloud.deck.model.full.FullCard.setLabels(java.util.List)' on a null object reference
	at it.niedermann.nextcloud.deck.remote.helpers.providers.CardDataProvider.goDeeper(CardDataProvider.java:153)
	at it.niedermann.nextcloud.deck.remote.helpers.providers.CardDataProvider.goDeeper(CardDataProvider.java:39)
	at it.niedermann.nextcloud.deck.remote.helpers.SyncHelper$1.onResponse(SyncHelper.java:98)
	at it.niedermann.nextcloud.deck.remote.helpers.SyncHelper$1.onResponse(SyncHelper.java:57)
	at it.niedermann.nextcloud.deck.remote.helpers.providers.CardDataProvider$1.onResponse(CardDataProvider.java:81)
	at it.niedermann.nextcloud.deck.remote.helpers.providers.CardDataProvider$1.onResponse(CardDataProvider.java:76)
	at it.niedermann.nextcloud.deck.remote.api.RequestHelper$ResponseConsumer.onResponse(RequestHelper.java:68)
	at com.nextcloud.android.sso.helper.Retrofit2Helper$1.lambda$enqueue$0(Retrofit2Helper.java:87)
	at com.nextcloud.android.sso.helper.Retrofit2Helper$1.$r8$lambda$<SNIP POTENTIAL TOKEN>(Unknown Source:0)
	at com.nextcloud.android.sso.helper.Retrofit2Helper$1$$ExternalSyntheticLambda0.run(Unknown Source:6)
	at java.lang.Thread.run(Thread.java:1012)

There were no issues server side. I've run it again just after that, and it loaded all the boards properly and I was able to use them.

I hope this helps.

desperateCoder added a commit that referenced this issue Feb 27, 2024
@stefan-niedermann
Copy link
Owner

Thanks everybody for your valuable help!

We merged the changes @desperateCoder made together with you and we will release these changes in 1.24.1. Especially a better handling with deleted boards and cards has been implemented - this should effectively eleminate the HTTP 403 related issues.

Leaving up to @desperateCoder how to proceed: Either keeping this as a general collecting issue or to close it and taking care about further issue in seperate topics to be more focused and not spamming subscribers with (for them) unrelated conversations.

@xarinatan
Copy link
Author

Thank you for incorporating that fix! it definitely is part of my issues as well even if it didn't completely fix it.

If it helps, we can close this bug for now, and I'll open a new one if I manage to get more details about what's going wrong with my specific setup. I still don't have it working (still gives me a 503 with a serverside "Error in application Index" in the logs), but I haven't had the time and energy to dig further into it as of currently, and technically speaking it's no longer a 403 or a flurry of errors, so we definitely made some progress here :)

@walrus543
Copy link

I also have the Connection rejected error message and I can't sync at all.

App Version: 1.24.1
App Version Code: 1024001
Server App Version: 1.11.3
App Flavor: fdroid

Files App Version Code: 30280290 (PROD)

---

OS Version: 4.19.306-evo-perf-g5be082752296(1709410152)
OS API Level: 34
Device: OnePlus8Pro
Manufacturer: OnePlus
Model (and Product): IN2020 (OnePlus8Pro)

---

it.niedermann.nextcloud.deck.exceptions.OfflineException: Connection rejected
	at it.niedermann.nextcloud.deck.remote.api.ServerCommunicationErrorHandler$Handler.handle(ServerCommunicationErrorHandler.java:52)
	at it.niedermann.nextcloud.deck.remote.api.ServerCommunicationErrorHandler.translateError(ServerCommunicationErrorHandler.java:28)
	at it.niedermann.nextcloud.deck.remote.api.RequestHelper$ResponseConsumer.onFailure(RequestHelper.java:95)
	at it.niedermann.nextcloud.deck.remote.api.RequestHelper$ResponseConsumer.onResponse(RequestHelper.java:70)
	at com.nextcloud.android.sso.helper.Retrofit2Helper$1.lambda$enqueue$0(Retrofit2Helper.java:87)
	at com.nextcloud.android.sso.helper.Retrofit2Helper$1.$r8$lambda$n0izO5V3AflskH7z1H8dSLmVKXo(Unknown Source:0)
	at com.nextcloud.android.sso.helper.Retrofit2Helper$1$$ExternalSyntheticLambda0.run(Unknown Source:6)
	at java.lang.Thread.run(Thread.java:1012)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants