[MS-1470] Scanning noew checks that there are not enough captures before updating the scanning progress state#1707
Merged
Conversation
…ore updating the scanning progress state
There was a problem hiding this comment.
Pull request overview
This PR addresses a race condition in the external credential OCR scanning flow where reaching the required number of captures could trigger the completion workflow more than once. It does so by preventing additional scanning-progress state updates once the required capture count has already been met, and adds tests to guard the behavior.
Changes:
- Gate
processImage()so it no longer appends scanned documents / updatesScanOcrState.ScanningInProgressoncecapturesRequiredis reached. - Add unit tests asserting no further scanning-progress updates occur after the required capture count is met.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| feature/external-credential/src/main/java/com/simprints/feature/externalcredential/screens/scanocr/ExternalCredentialScanOcrViewModel.kt | Adds capture-count gating before updating scanning progress state to prevent duplicate completion triggers. |
| feature/external-credential/src/test/java/com/simprints/feature/externalcredential/screens/scanocr/ExternalCredentialScanOcrViewModelTest.kt | Adds regression tests for “do not update progress after reaching required captures” behavior. |
meladRaouf
approved these changes
Jun 15, 2026
|
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.



JIRA ticket
Will be released in: 2026.2.0
Root cause analysis (for bugfixes only)
First known affected version: 2026.2.0
Sometimes the OCR completion function was called twice due to race condition. We haven't captured this behaviour earlier due to low chance of having the race condition in the first place, but now this is addressed.
Notable changes
ViewModel now checks if the amount of scans hasn't been reached to avoid calling the completion workflow more than once.
Testing guidance
Run the standard OCR tests for the NHIS and GhanaID cards multiple times, and verify that there are no runtime crashes.
Additional work checklist