Skip to content

fix: show feedback when a scanned QR code contains unsupported data#11248

Open
mvanhorn wants to merge 2 commits into
thunderbird:mainfrom
mvanhorn:fix/8520-qrcode-scan-feedback
Open

fix: show feedback when a scanned QR code contains unsupported data#11248
mvanhorn wants to merge 2 commits into
thunderbird:mainfrom
mvanhorn:fix/8520-qrcode-scan-feedback

Conversation

@mvanhorn

@mvanhorn mvanhorn commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Contribution Summary

Linked Issue/Ticket: Refs #8520
RFC / Technical Design (if applicable): N/A

Description

The "Import via QR code" flow silently ignores QR codes whose payload fails validation. QrCodeScannerViewModel.handleQrCodeScanned records the payload hash in unsupportedPayloadHashes and returns with no state change, so the bottom bar keeps showing the generic help text and the user sees no reaction at all. That is the top-reported symptom in #8520: the camera clearly frames the code (it scans fine in other apps), but nothing happens because desktop exports with invalid payload data (blank authentication type, missing encryption settings) are decoded and rejected without feedback.

This adds a DisplayText.UnsupportedQrCode variant to QrCodeScannerContract, sets it in the unsupported branch of handleQrCodeScanned, and renders it in QrCodeScannerView.buildString with a new migration_qrcode_unsupported_code string. A subsequent successful scan restores the progress text through the existing handleSupportedPayload path. Only the base values/strings.xml is edited; translations flow through Weblate.

Scope note: this converts the silent failure into actionable feedback. It deliberately does not touch desktop-side QR generation (different repo) or device-specific camera lens selection, which the issue thread tracks separately, so the body references the issue with Refs rather than Closes.

Screen Shots

N/A: the change adds one line of text to the existing scanner bottom bar, shown only when an unsupported code is scanned.

AI Disclosure

Select one of the following (mandatory)

  • This contribution does not include any changes created or assisted by AI.
  • This contribution includes changes assisted by AI.
  • This contribution includes changes created by AI.

Contribution Checklist

  • I have read and affirm that my contribution adheres to Mozilla’s Community Participation Guidelines
  • This contribution is in Kotlin where possible
  • This contribution does not use merge commits
  • This contribution adheres to the existing codestyle (run gradlew spotlessCheck to check and gradlew spotlessApply to format your source code; will be checked by CI).
  • This contribution does not break existing unit tests (run gradlew testDebugUnitTest; will be checked by CI).
  • This contribution includes tests for any new functionality, and maintains tests for any updated functionality.
  • This contribution adheres to our Engineering process (RFC/Technical Design/ADR)
  • This PR has a descriptive title and body that accurately outlines all changes made, and contains a reference to any issues that it fixes (e.g. Closes #XXX or Fixes #XXX).

@mvanhorn
mvanhorn requested a review from a team as a code owner July 8, 2026 06:45
@mvanhorn
mvanhorn requested a review from dani-zilla July 8, 2026 06:45
@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Validation Passed: All report and feature-flag labels are correctly set.

@dani-zilla dani-zilla added the report: include Include changes in user-facing reports. label Jul 23, 2026
@dani-zilla

Copy link
Copy Markdown
Contributor

Tested with a few QR codes, some working, others intentionally broken. Smoke test passed. However, it seems like 3 of the new tests are not:

> Task :feature:migration:qrcode:testDebugUnitTest FAILED

QrCodeScannerViewModelTest > user scans supported QR code after unsupported QR code FAILED
    kotlin.UninitializedPropertyAccessException at Log.kt:34
        Caused by: kotlin.UninitializedPropertyAccessException at QrCodeScannerViewModelTest.kt:164

QrCodeScannerViewModelTest > user scans unsupported QR code FAILED
    kotlin.UninitializedPropertyAccessException at Log.kt:34
        Caused by: kotlin.UninitializedPropertyAccessException at QrCodeScannerViewModelTest.kt:151

QrCodeScannerViewModelTest > user scans same unsupported QR code more than once FAILED
    kotlin.UninitializedPropertyAccessException at Log.kt:34
        Caused by: kotlin.UninitializedPropertyAccessException at QrCodeScannerViewModelTest.kt:180

The three failing QrCodeScannerViewModel tests hit the uninitialized global
Log.logger when the ViewModel logs. Initialize it with TestLogger() in
setUp(), matching the pattern used by other feature tests.
@mvanhorn

Copy link
Copy Markdown
Contributor Author

Good catch on the three — they were failing because Log.logger isn't initialized in the test, so the ViewModel's logging calls hit the uninitialized global and threw. Added Log.logger = TestLogger() in setUp(), matching the pattern the other feature tests use. I couldn't run the full Gradle suite locally, so worth a CI re-run to confirm all three go green.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

report: include Include changes in user-facing reports.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants