appwrite / sdk-for-android

[READ-ONLY] Official Appwrite Android SDK 💚 🤖
https://appwrite.io
BSD 3-Clause "New" or "Revised" License
114 stars 20 forks source link

🐛 Bug Report: getSession() throwing NullPointerException for sessions being created via email / password #18

Closed SebastianTMo closed 2 years ago

SebastianTMo commented 2 years ago

👟 Reproduction steps

Appwrite Version 0.12 / SDK Version 0.3.0 Create a Session via email / password, try to get the session via getSession()

👍 Expected behavior

Get the respective Session

👎 Actual Behavior

NullPointerException due to requiring providerToken not to be nullable. https://github.com/appwrite/sdk-for-android/blob/2d0eecda71f1d85a73f658a9ae08656197e204d4/library/src/main/java/io/appwrite/models/Session.kt#L147 Unfortunately this entry seems to be null when creating a session via email / password.

🎲 Appwrite version

Different version (specify in environment)

💻 Operating system

Linux

🧱 Your Environment

No response

👀 Have you spent some time to check if this issue has been raised before?

🏢 Have you read the Code of Conduct?

lohanidamodar commented 2 years ago

@SebastianTMo Thank your for raising an issue, we will get back to you soon.

SSederberg commented 2 years ago

Since it's related to sessions I'll put it here. Appwrite Version 0.13.4.304 SDK Version 0.5.0

I'm attempting to get session by ID or using "current" using var sessionResponse = account.getSession(String) Expected to return a valid Session ID, instead when attempting to parse providerAccessTokenExpiry = (map["providerAccessTokenExpiry"] as Number).toLong() it will throw a NullPointerException java.lang.NullPointerException: null cannot be cast to non-null type kotlin.Number at io.appwrite.models.Session$Companion.from(Session.kt:186) at io.appwrite.services.Account$getSession$converter$1.invoke(Account.kt:787) at io.appwrite.services.Account$getSession$converter$1.invoke(Account.kt:786) at io.appwrite.Client$awaitResponse$2$1.onResponse(Client.kt:498) at okhttp3.internal.connection.RealCall$AsyncCall.run(RealCall.kt:519) 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:764)

Running account.get() beforehand does not change outcome. OS: Ubuntu Server LTS Environment: Set to development with APP_OPTIONS_ABUSE disabled.

abnegate commented 2 years ago

This should no longer be an issue with Appwrite 0.14+ 👍