Skip to content

[MS-1470] Scanning noew checks that there are not enough captures before updating the scanning progress state#1707

Merged
alexandr-simprints merged 1 commit into
release/2026.2.0from
MS-1470-crashlytics-linked-issue-get-best-readout-based-on-confidence-use-case-invoke
Jun 16, 2026
Merged

[MS-1470] Scanning noew checks that there are not enough captures before updating the scanning progress state#1707
alexandr-simprints merged 1 commit into
release/2026.2.0from
MS-1470-crashlytics-linked-issue-get-best-readout-based-on-confidence-use-case-invoke

Conversation

@alexandr-simprints

Copy link
Copy Markdown
Contributor

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

  • Effect on other features and security has been considered

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 / updates ScanOcrState.ScanningInProgress once capturesRequired is 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.

@sonarqubecloud

Copy link
Copy Markdown

@alexandr-simprints alexandr-simprints merged commit 9020b36 into release/2026.2.0 Jun 16, 2026
15 checks passed
@alexandr-simprints alexandr-simprints deleted the MS-1470-crashlytics-linked-issue-get-best-readout-based-on-confidence-use-case-invoke branch June 16, 2026 10:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants