Repository navigation
android: decode password-login payload leniently - #420
Merged
Merged
Conversation
The non-2FA branch decoded the LoginResponse with the strict default Json, so any field the DTO does not model (e.g. user.created_at) failed the sign-in. Reuse the ApiClient decoder, which ignores unknown keys.
Mira PR WalkthroughThis PR fixes a password-only login regression on Android caused by strict JSON decoding. The fix exposes the lenient JSON decoder (with ignoreUnknownKeys and coerceInputValues) from ApiClient and reuses it in LoginViewModel, ensuring both password-only and 2FA login paths decode server responses consistently. Previously, unknown fields like user.created_at caused password login to fail while 2FA worked via Retrofit's lenient converter. Confidence: 5/5 ◉◉◉◉◉ Safe to merge
2 files reviewed
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Since #414 the password-only login path decodes the
LoginResponseout of theJsonElementpayload with the strict defaultJsoninstance. Any field the DTO does not model fails the whole sign-in; in practiceuser.created_atdoes, so password login without 2FA is broken against current servers:The 2FA path was unaffected because it goes through the Retrofit converter, which already ignores unknown keys.
Fix
Expose the
ApiClientdecoder (ignoreUnknownKeys,coerceInputValues) and reuse it inLoginViewModel, so both paths decode the same way.Testing
Reproduced against a local 4.23.x server (
android/devtooling, separate PR to follow); password login succeeds after the change, 2FA path unchanged.