LemmyNet/jerboa

Cannot login on private instance

Closed this issue · 4 comments

Jerboa Version

0.0.66

Android Version + Phone

Android 14, Oneplus 11 5G

Describe The Bug

I have set up a selfhosted private instance of lemmy.

Attempting to log in to my instance throws the following error (full stacktrace below):

04-21 22:18:11.157 20138 20138 D login   : io.ktor.serialization.JsonConvertException: Illegal input: Unexpected JSON token at offset 76: Expected start of the array '[', but had 'n' instead at path: $.protocols
04-21 22:18:11.157 20138 20138 D login   : JSON input: .....ersion":"0.19.3"},"protocols":null,"usage":{"users":{"total".....
04-21 22:18:11.157 20138 20138 D login   : 	at io.ktor.serialization.kotlinx.KotlinxSerializationConverter.deserialize(Unknown Source:317)

From what I can understand, the protocol is not expected to be null.
The GET request /nodeinfo/2.0.json on my instance returns:

{
  "version": "2.0",
  "software": {
    "name": "lemmy",
    "version": "0.19.3"
  },
  "protocols": null,
  "usage": {
    "users": {
      "total": 7,
      "activeHalfyear": 1,
      "activeMonth": 1
    },
    "localPosts": 1,
    "localComments": 1
  },
  "openRegistrations": true
}

where you can see the protocol is null. I did not know any other private instances to try.

I have tried other Android clients, but they failed in the same way. However, I have successfully logged in with a desktop client (Lemoa).

To Reproduce

  1. try to login to a private instance
  2. See the login failed toast

In the case of a crash or when relevant include the logs

04-21 22:18:11.157 20138 20138 D login : io.ktor.serialization.JsonConvertException: Illegal input: Unexpected JSON token at offset 76: Expected start of the array '[', but had 'n' instead at path: $.protocols
04-21 22:18:11.157 20138 20138 D login : JSON input: .....ersion":"0.19.3"},"protocols":null,"usage":{"users":{"total".....
04-21 22:18:11.157 20138 20138 D login : at io.ktor.serialization.kotlinx.KotlinxSerializationConverter.deserialize(Unknown Source:317)
04-21 22:18:11.157 20138 20138 D login : at io.ktor.serialization.ContentConverterKt$deserialize$$inlined$map$1$2.emit(Unknown Source:162)
04-21 22:18:11.157 20138 20138 D login : at kotlinx.coroutines.flow.SafeFlow.collect(Unknown Source:89)
04-21 22:18:11.157 20138 20138 D login : at io.ktor.serialization.ContentConverterKt$deserialize$$inlined$map$1.collect(Unknown Source:47)
04-21 22:18:11.157 20138 20138 D login : at kotlin.text.RegexKt.firstOrNull(Unknown Source:72)
04-21 22:18:11.157 20138 20138 D login : at kotlin.ResultKt.deserialize(Unknown Source:81)
04-21 22:18:11.157 20138 20138 D login : at io.ktor.client.plugins.contentnegotiation.ContentNegotiation.convertResponse$ktor_client_content_negotiation(Unknown Source:243)
04-21 22:18:11.157 20138 20138 D login : at io.ktor.client.HttpClient$2.invokeSuspend(Unknown Source:441)
04-21 22:18:11.157 20138 20138 D login : at io.ktor.client.HttpClient$2.invoke(SourceFile:2)
04-21 22:18:11.157 20138 20138 D login : at io.ktor.client.HttpClient$2.invoke(SourceFile:6)
04-21 22:18:11.157 20138 20138 D login : at io.ktor.util.pipeline.SuspendFunctionGun.loop(Unknown Source:35)
04-21 22:18:11.157 20138 20138 D login : at io.ktor.util.pipeline.SuspendFunctionGun.proceed(Unknown Source:21)
04-21 22:18:11.157 20138 20138 D login : at io.ktor.client.HttpClient$4.invokeSuspend(Unknown Source:167)
04-21 22:18:11.157 20138 20138 D login : at io.ktor.client.HttpClient$4.invoke(Unknown Source:40)
04-21 22:18:11.157 20138 20138 D login : at io.ktor.util.pipeline.SuspendFunctionGun.loop(Unknown Source:35)
04-21 22:18:11.157 20138 20138 D login : at io.ktor.util.pipeline.SuspendFunctionGun.proceed(Unknown Source:21)
04-21 22:18:11.157 20138 20138 D login : at io.ktor.util.pipeline.SuspendFunctionGun.proceedWith(Unknown Source:7)
04-21 22:18:11.157 20138 20138 D login : at io.ktor.client.plugins.HttpCallValidator$Companion$install$1.invokeSuspend(Unknown Source:133)
04-21 22:18:11.157 20138 20138 D login : at io.ktor.client.plugins.HttpCallValidator$Companion$install$1.invoke(Unknown Source:46)
04-21 22:18:11.157 20138 20138 D login : at io.ktor.util.pipeline.SuspendFunctionGun.loop(Unknown Source:35)
04-21 22:18:11.157 20138 20138 D login : at io.ktor.util.pipeline.SuspendFunctionGun.proceed(Unknown Source:21)
04-21 22:18:11.157 20138 20138 D login : at io.ktor.util.pipeline.SuspendFunctionGun.execute$ktor_utils(Unknown Source:23)
04-21 22:18:11.157 20138 20138 D login : at io.ktor.util.pipeline.Pipeline.execute(Unknown Source:195)
04-21 22:18:11.157 20138 20138 D login : at io.ktor.client.call.HttpClientCall.bodyNullable(Unknown Source:173)
04-21 22:18:11.157 20138 20138 D login : at it.vercruysse.lemmyapi.LemmyApi.getNodeInfo-gIAlu-s(Unknown Source:125)
04-21 22:18:11.157 20138 20138 D login : at it.vercruysse.lemmyapi.LemmyApi$getNodeInfo$1.invokeSuspend(Unknown Source:12)
04-21 22:18:11.157 20138 20138 D login : at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(Unknown Source:8)
04-21 22:18:11.157 20138 20138 D login : at kotlinx.coroutines.DispatchedTask.run(Unknown Source:112)
04-21 22:18:11.157 20138 20138 D login : at kotlinx.coroutines.EventLoopImplPlatform.processUnconfinedEvent(Unknown Source:23)
04-21 22:18:11.157 20138 20138 D login : at kotlinx.coroutines.internal.DispatchedContinuation.resumeWith(Unknown Source:74)
04-21 22:18:11.157 20138 20138 D login : at io.ktor.util.pipeline.SuspendFunctionGun.resumeRootWith(Unknown Source:24)
04-21 22:18:11.157 20138 20138 D login : at io.ktor.util.pipeline.SuspendFunctionGun.loop(Unknown Source:15)
04-21 22:18:11.157 20138 20138 D login : at io.ktor.util.pipeline.SuspendFunctionGun$continuation$1.resumeWith(Unknown Source:22)
04-21 22:18:11.157 20138 20138 D login : at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(Unknown Source:31)
04-21 22:18:11.157 20138 20138 D login : at kotlinx.coroutines.DispatchedTask.run(Unknown Source:112)
04-21 22:18:11.157 20138 20138 D login : at android.os.Handler.handleCallback(Handler.java:958)
04-21 22:18:11.157 20138 20138 D login : at android.os.Handler.dispatchMessage(Handler.java:99)
04-21 22:18:11.157 20138 20138 D login : at android.os.Looper.loopOnce(Looper.java:257)
04-21 22:18:11.157 20138 20138 D login : at android.os.Looper.loop(Looper.java:368)
04-21 22:18:11.157 20138 20138 D login : at android.app.ActivityThread.main(ActivityThread.java:8826)
04-21 22:18:11.157 20138 20138 D login : at java.lang.reflect.Method.invoke(Native Method)
04-21 22:18:11.157 20138 20138 D login : at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:572)
04-21 22:18:11.157 20138 20138 D login : at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1049)

Hmmm, Lemmy is supposed to return activitypub protocol. I'll take a look to see if it can be null according to the spec. But this is rather bug in Lemmy than Jerboa.

https://lemmy.ml/nodeinfo/2.0.json

@dessalines

Nvm from the Lemmy code this is on purpose. I'll fix this.

https://github.com/LemmyNet/lemmy/blob/main/crates/routes/src/nodeinfo.rs

Edit:

Actually according to the nodeinfo spec, there should be minimum 1 protocol?

http://nodeinfo.diaspora.software/docson/index.html#/ns/schema/2.0

Ok, thank you for diving deep into it.

So, maybe I should open an issue with Lemmy instead?

I'll make an issue in the meantime I'll fix it on my side too. (As Lemmy instances are slow to update, so I ll have to support it)