Skip to content

[PM-30870] Fix editing blocked autofill URIs #6532

Open
andrebispo5 wants to merge 7 commits intomainfrom
pm-30870/bugfix-edit-blocked-uri
Open

[PM-30870] Fix editing blocked autofill URIs #6532
andrebispo5 wants to merge 7 commits intomainfrom
pm-30870/bugfix-edit-blocked-uri

Conversation

@andrebispo5
Copy link
Contributor

🎟️ Tracking

https://bitwarden.atlassian.net/browse/PM-30870

📔 Objective

Fix an issue where editing a blocked autofill URI would incorrectly trigger duplicate validation errors. Previously, when a user attempted to edit an existing blocked URI, the validation would compare against the full list including the original URI, causing false duplicate errors even when saving the same value or making minor modifications.

Changes

  • Add originalUri parameter to track which URI is being edited
  • Exclude the original URI from duplicate validation during edits
  • Remove the original URI before adding the updated value to properly replace it

📸 Screenshots

Screen.Recording.2026-02-13.at.12.17.11.mov

@andrebispo5 andrebispo5 requested review from a team and david-livefront as code owners February 13, 2026 12:20
Copilot AI review requested due to automatic review settings February 13, 2026 12:20
@github-actions github-actions bot added the app:password-manager Bitwarden Password Manager app context label Feb 13, 2026
Copy link

Copilot AI left a comment

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 fixes an issue where editing a blocked autofill URI incorrectly triggered duplicate validation errors. The fix adds an originalUri parameter to track which URI is being edited and excludes it from duplicate validation, allowing users to save edits without false positive errors.

Changes:

  • Added originalUri parameter to SaveUri action to track which URI is being edited
  • Modified duplicate validation logic to exclude the original URI when editing
  • Updated URI replacement logic to properly remove the original before adding the updated value
  • Added comprehensive test coverage for edit scenarios including same-value edits and duplicate detection

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
BlockAutoFillViewModel.kt Enhanced handleSaveUri to filter out originalUri from validation and properly replace URIs during edits; updated SaveUri action to include optional originalUri parameter
BlockAutoFillScreen.kt Updated onSaveClick callback signature to accept originalUri and pass it from dialog state to the action
BlockAutoFillViewModelTest.kt Added three new tests covering URI replacement, same-value editing, and duplicate detection during edits

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions
Copy link
Contributor

github-actions bot commented Feb 13, 2026

Logo
Checkmarx One – Scan Summary & Details92330daf-fecf-4e9c-87f8-c82fc31fd0c7

Great job! No new security vulnerabilities introduced in this pull request

@codecov
Copy link

codecov bot commented Feb 13, 2026

Codecov Report

❌ Patch coverage is 93.75000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 86.39%. Comparing base (e939b20) to head (076dc46).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...s/autofill/blockautofill/BlockAutoFillViewModel.kt 91.66% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6532      +/-   ##
==========================================
+ Coverage   86.35%   86.39%   +0.04%     
==========================================
  Files         789      777      -12     
  Lines       56424    56200     -224     
  Branches     8175     8175              
==========================================
- Hits        48724    48555     -169     
+ Misses       4853     4801      -52     
+ Partials     2847     2844       -3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@andrebispo5 andrebispo5 added the t:bug Change Type - Bug label Feb 13, 2026
// When editing, exclude the original URI from duplicate validation
val existingUrisForValidation = action.originalUri?.let { original ->
settingsRepository.blockedAutofillUris.filter { it != original }
} ?: settingsRepository.blockedAutofillUris
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we use proper chain formatting:

val existingUrisForValidation = action
    .originalUri
    ?.let { original ->
        settingsRepository.blockedAutofillUris.filter { it != original }
    }
    ?: settingsRepository.blockedAutofillUris

@github-actions github-actions bot removed the t:bug Change Type - Bug label Feb 13, 2026
val addEditDialog = dialog as BlockAutoFillState.DialogState.AddEdit
assertEquals("http://b.com", addEditDialog.uri)
assertEquals("http://a.com", addEditDialog.originalUri)
assert(addEditDialog.errorMessage != null)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we just assert the entire dialog state instead.

Also, we should be using assertEquals not assert

val addEditDialog = dialog as BlockAutoFillState.DialogState.AddEdit
assertEquals("http://b.com", addEditDialog.uri)
assertEquals("http://a.com", addEditDialog.originalUri)
assertNotNull(addEditDialog.errorMessage)
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should be asserting the whole state

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oh sorry I misread your comment above... for sure!

assertEquals(expectedState, viewModel.stateFlow.value)
}

@Suppress("MaxLineLength")
Copy link
Collaborator

Choose a reason for hiding this comment

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

This suppression is not needed?

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

Labels

app:password-manager Bitwarden Password Manager app context

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants