Skip to content

Prevent crash if there was an exception getting login items for URL#8166

Merged
CrisBarreiro merged 1 commit intodevelopfrom
feature/cris/autofill/get-credentials-for-domain-prevent-crash
Apr 7, 2026
Merged

Prevent crash if there was an exception getting login items for URL#8166
CrisBarreiro merged 1 commit intodevelopfrom
feature/cris/autofill/get-credentials-for-domain-prevent-crash

Conversation

@CrisBarreiro
Copy link
Copy Markdown
Collaborator

@CrisBarreiro CrisBarreiro commented Mar 31, 2026

Task/Issue URL: https://app.asana.com/1/137249556945/project/1203822806345703/task/1213886927706691?focus=true

Description

Steps to test this PR

Feature 1

  • Fresh install
  • Create a password for fill.dev
  • Apply patch, install again
  • Open fill.dev
  • Check app doesn't crash

Patches

Subject: [PATCH] Force exception on read
---
Index: autofill/autofill-impl/src/main/java/com/duckduckgo/autofill/store/keys/SecureStorageKeyStore.kt
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/autofill/autofill-impl/src/main/java/com/duckduckgo/autofill/store/keys/SecureStorageKeyStore.kt b/autofill/autofill-impl/src/main/java/com/duckduckgo/autofill/store/keys/SecureStorageKeyStore.kt
--- a/autofill/autofill-impl/src/main/java/com/duckduckgo/autofill/store/keys/SecureStorageKeyStore.kt	(revision c626e494540a136b957a810912bb7e281aba5c3d)
+++ b/autofill/autofill-impl/src/main/java/com/duckduckgo/autofill/store/keys/SecureStorageKeyStore.kt	(date 1774962387460)
@@ -325,6 +325,9 @@
     }
 
     override suspend fun getKey(keyName: String): ByteArray? {
+        if (keyName != "KEY_L1KEY") {
+            throw SecureStorageException.InternalSecureStorageException("test")
+        }
         return withContext(dispatcherProvider.io()) {
             val harmonyFlags = harmonyFlags()
 

UI changes

Before After
!(Upload before screenshot) (Upload after screenshot)

Note

Low Risk
Low risk: change is localized to getCredentials and only alters error handling by returning an empty result on unexpected exceptions while preserving coroutine cancellation.

Overview
Prevents crashes during autofill credential lookup by wrapping SecureStoreBackedAutofillStore.getCredentials secure-storage reads/filtering in runCatching.

On failure it now calls ensureActive() (so cancellations still propagate) and returns an empty credentials list instead of throwing.

Written by Cursor Bugbot for commit c626e49. This will update automatically on new commits. Configure here.

Copy link
Copy Markdown
Collaborator Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@CrisBarreiro CrisBarreiro marked this pull request as ready for review March 31, 2026 13:54
@CrisBarreiro CrisBarreiro requested a review from CDRussell March 31, 2026 13:54
@CDRussell
Copy link
Copy Markdown
Member

@CrisBarreiro i'm still seeing it crash with the patch applied
Screenshot 2026-04-01 at 11 54 18

Copy link
Copy Markdown
Member

@CDRussell CDRussell left a comment

Choose a reason for hiding this comment

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

Discussed #8166 (comment)

  • it does still crash because something else is accessing autofill in that scenario which isn't going through the protected path changed in this PR (basically, ignoring the patch it's a fine change)
  • longer term, we want to return Result to better encapsulate the more nuanced return types but making this one narrow part safer (this PR) is a good start

@CrisBarreiro CrisBarreiro merged commit e40664b into develop Apr 7, 2026
20 of 22 checks passed
@CrisBarreiro CrisBarreiro deleted the feature/cris/autofill/get-credentials-for-domain-prevent-crash branch April 7, 2026 08:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants