Improved logging around preApproval screens - #243
Open
Hopsaheysa wants to merge 10 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Addresses issue #232 by tightening PreApprovalScreen decoding so missing required fields no longer get silently substituted, and by adding additional logging to help diagnose backend payload problems around pre-approval UI screens.
Changes:
- Treat missing
heading/messageas a decoding failure forPreApprovalScreen(instead of defaulting to empty strings), with explicit error logs. - Update
OperationUIDataDeserializerpre-approval parsing to better handle pluralpreApprovalScreensarrays and skip invalid entries. - Add unit tests covering missing required fields and mixed-validity screen arrays.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
library/src/test/java/JsonDeserializationTests.kt |
Adds regression tests for required-field enforcement and mixed-validity pre-approval screen arrays. |
library/src/main/java/com/wultra/android/mtokensdk/api/operation/PreApprovalScreenDeserializer.kt |
Enforces required heading/message during deserialization and adds error/warn logs for invalid/legacy payloads. |
library/src/main/java/com/wultra/android/mtokensdk/api/operation/OperationUIDataDeserializer.kt |
Adjusts decoding logic and logging around legacy vs plural pre-approval screen payload formats. |
Hopsaheysa
changed the base branch from
develop
to
issues/240-proximity-improvements
June 24, 2026 15:08
# Conflicts: # docs/Migration-3.0.md # docs/Using-Operations-Service.md # library/src/main/java/com/wultra/android/mtokensdk/api/operation/model/UserOperation.kt # library/src/main/java/com/wultra/android/mtokensdk/operation/OperationsService.kt
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 7 out of 7 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (4)
library/src/main/java/com/wultra/android/mtokensdk/api/operation/OperationUIDataDeserializer.kt:69
- When both legacy
preApprovalScreenand newpreApprovalScreensare present, a malformedpreApprovalScreensvalue (non-array) returns early and prevents falling back to the legacy object. Previously (viasafeDeserializeArray), legacy decoding could still succeed if the plural field was invalid. Consider logging the error but continuing to try legacy parsing when available, and avoid catchingThrowablewhen parsing individual screens.
val el = obj.get("preApprovalScreens")
if (!el.isJsonArray) {
WMTLogger.e("'preApprovalScreens' is present but is not a JSON array — ignoring.")
return null
}
docs/Changelog.md:14
- Changelog entry references issue
#226in the link text but links to issue#232in the URL. This looks like a typo and makes the changelog inconsistent.
- Improved `PreApprovalScreen` decoding & logging. [(#226)](https://github.com/wultra/mtoken-sdk-android/issues/232).
docs/Using-Operations-Service.md:839
- The
ProximityChecksnippet now showsvar timestampReceived: ZonedDateTimewithout an initializer, but the implementation defaults it toZonedDateTime.now()and the setter isinternal. Updating the snippet keeps the docs aligned with the actual API and the surrounding comment (“Captured automatically at creation”).
* Timestamp when the operation was scanned (QR Code) or delivered to the device (Deeplink).
* Captured automatically at creation. The SDK adjusts this to server time during authorization.
*/
var timestampReceived: ZonedDateTime
}
library/src/test/java/JsonDeserializationTests.kt:607
- This test can pass even if
uifails to deserialize entirely (sinceop!!.ui?.preApprovalScreenswould be null). Adding an explicit assertion thatuiis not null ensures the test only validates the intended behavior: skipping the invalid pre-approval screen.
val op = response.responseObject.firstOrNull()
Assert.assertNotNull(op)
Assert.assertNull("Screen should fail to decode when heading/message are missing", op!!.ui?.preApprovalScreens)
}
Member
Author
|
forgotten but not lost |
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.
#232
heading and message are required fields but the decoder silently substituted empty strings (?: "") when they were missing.
fail decoding of that screen and add log about it
this PR depends on changes of the changelog + mig. guide in #240