Skip to content

Conversation

@petrows
Copy link

@petrows petrows commented Dec 1, 2025

In this case web application adds one more Json value isNewUser and it causes exception in AuthResponse class. Add annotation to ignore unknown keys.

Application now works correctly for login via Google. Additionally, i think it is better to ignore unknown keys in general, as this might affect application stability on web-app update.

Exception fixed:

onCookiesChanged
kotlinx.serialization.json.internal.JsonDecodingException: Encountered an unknown key 'isNewUser' at offset 191 at path: $
Use 'ignoreUnknownKeys = true' in 'Json {}' builder or '@JsonIgnoreUnknownKeys' annotation to ignore unknown keys.
JSON input: .....9","expiresAt":1767206987022,"isNewUser":false}
	at kotlinx.serialization.json.internal.AbstractJsonLexer.failOnUnknownKey(AbstractJsonLexer.kt:579)
	at kotlinx.serialization.json.internal.StreamingJsonDecoder.handleUnknown(StreamingJsonDecoder.kt:258)
	at kotlinx.serialization.json.internal.StreamingJsonDecoder.decodeObjectIndex(StreamingJsonDecoder.kt:243)
	at kotlinx.serialization.json.internal.StreamingJsonDecoder.decodeElementIndex(StreamingJsonDecoder.kt:178)
	at ru.slartus.boostbuddy.data.repositories.models.AuthResponse$$serializer.deserialize(AuthResponse.kt:5)
	at ru.slartus.boostbuddy.data.repositories.models.AuthResponse$$serializer.deserialize(AuthResponse.kt:5)
	at kotlinx.serialization.json.internal.StreamingJsonDecoder.decodeSerializableValue(StreamingJsonDecoder.kt:69)
	at kotlinx.serialization.json.Json.decodeFromString(Json.kt:149)
	at ru.slartus.boostbuddy.components.auth.AuthComponentImpl$onCookiesChanged$1.invokeSuspend(AuthComponent.kt:77)
	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
	at kotlinx.coroutines.internal.DispatchedContinuationKt.resumeCancellableWith(DispatchedContinuation.kt:375)
	at kotlinx.coroutines.intrinsics.CancellableKt.startCoroutineCancellable(Cancellable.kt:26)
	at kotlinx.coroutines.CoroutineStart.invoke(CoroutineStart.kt:358)
	at kotlinx.coroutines.AbstractCoroutine.start(AbstractCoroutine.kt:134)
	at kotlinx.coroutines.BuildersKt__Builders_commonKt.launch(Builders.common.kt:53)
	at kotlinx.coroutines.BuildersKt.launch(Unknown Source:1)
	at kotlinx.coroutines.BuildersKt__Builders_commonKt.launch$default(Builders.common.kt:44)
	at kotlinx.coroutines.BuildersKt.launch$default(Unknown Source:1)
	at ru.slartus.boostbuddy.components.auth.AuthComponentImpl.onCookiesChanged(AuthComponent.kt:42)
	at ru.slartus.boostbuddy.ui.screens.AuthScreenKt$AuthScreen$2$3$1$1.invoke(AuthScreen.kt:194)
	at ru.slartus.boostbuddy.ui.screens.AuthScreenKt$AuthScreen$2$3$1$1.invoke(AuthScreen.kt:194)
	at ru.slartus.boostbuddy.ui.widgets.WebViewKt$WebView$webView$1$1$3.onLoadResource(WebView.kt:99)
	at WV.k00.a(chromium-TrichromeWebViewGoogle6432.aab-stable-699813538:12)
	at WV.r7.handleMessage(chromium-TrichromeWebViewGoogle6432.aab-stable-699813538:510)
	at android.os.Handler.dispatchMessage(Handler.java:132)
	at android.os.Looper.dispatchMessage(Looper.java:333)
	at android.os.Looper.loopOnce(Looper.java:263)
	at android.os.Looper.loop(Looper.java:367)
	at android.app.ActivityThread.main(ActivityThread.java:9282)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:566)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:929)

In this case web application adds one more Json value `isNewUser` and it causes exception in `AuthResponse` class. Add annotation to ignore unknown keys - application now works correctly for login via Google
@slartus slartus self-requested a review December 2, 2025 04:24
Copy link
Owner

@slartus slartus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

в целом, исправление верное, но лучше json с настройками зарегать в DI и брать его из DI в AuthComponentImpl и для создания http-клиента.
если лень исправлять ПР, я сделаю сам

@petrows
Copy link
Author

petrows commented Dec 2, 2025

Привет, спасибо аз ревью!

в целом, исправление верное, но лучше json с настройками зарегать в DI и брать его из DI в AuthComponentImpl и для создания http-клиента.
Мне не лень, но такая переделка уже для меня сложновата - думаю не смогу красиво сделать.

Вообще, я посмотрел по коду, похоже реально используется только accessToken, предлагаю просто забить на isNewUser, судя по логике эта переменная нужна только для того что бы Welcome-screen отобразить, думаю вообще смысла особо нет заморачиваться.

@slartus
Copy link
Owner

slartus commented Dec 3, 2025

Привет, спасибо аз ревью!

в целом, исправление верное, но лучше json с настройками зарегать в DI и брать его из DI в AuthComponentImpl и для создания http-клиента.
Мне не лень, но такая переделка уже для меня сложновата - думаю не смогу красиво сделать.

Вообще, я посмотрел по коду, похоже реально используется только accessToken, предлагаю просто забить на isNewUser, судя по логике эта переменная нужна только для того что бы Welcome-screen отобразить, думаю вообще смысла особо нет заморачиваться.

на само свойство забить можно, но краш пофиксить придется

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

Successfully merging this pull request may close these issues.

2 participants