Skip to content

[PM-41295] feat: Detect and fill extended address for identity autofill - #7371

Draft
aj-rosado wants to merge 1 commit into
PM-41294/identity-autofill-multi-partition-pipelinefrom
PM-41295/identity-autofill-multiple-address
Draft

[PM-41295] feat: Detect and fill extended address for identity autofill#7371
aj-rosado wants to merge 1 commit into
PM-41294/identity-autofill-multi-partition-pipelinefrom
PM-41295/identity-autofill-multiple-address

Conversation

@aj-rosado

Copy link
Copy Markdown
Contributor

🎟️ Tracking

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

📔 Objective

Adds heuristic detection and fill support for a second/extended address line (e.g. apartment,
suite, unit) in identity autofill.

  • Classifies a field as AddressExtended via id/hint/HTML attribute heuristics or the OS
    address-line2 autofill hint.
  • Maps AddressExtended to the vault Identity's address2 when filling.

📸 Screenshots

N/A — no UI changes.

@aj-rosado aj-rosado added the ai-review Request a Claude code review label Sep 9, 2026
@github-actions github-actions Bot added app:password-manager Bitwarden Password Manager app context t:feature Change Type - Feature Development labels Sep 9, 2026
@github-actions

github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

🤖 Bitwarden Claude Code Review

Overall Assessment: REQUEST CHANGES

Reviewed the addition of an AddressExtended identity partition — a new AutofillView subtype, hint enum value, OS/W3C hint mappings, HTML and idEntry/hint heuristics, and the address2 fill mapping. All three exhaustive when sites over AutofillView.Identity (FilledDataBuilderImpl, AutofillParserImpl.updateWebsiteIfNecessary, AutofillViewExtensions.buildListAutofillValueOrNull) plus both field-key tables were updated consistently, and no other registry of identity view types was missed. The OS-hint path (extendedAddress, aptNumber, and Chrome's verbatim address-line2) is correct and well covered by tests.

The heuristic path has a detection problem rooted in toLowerCaseAndStripNonAlpha() stripping digits before comparison: the line-1/line-2 discriminator is erased, so address2 and addressLine2 fields are classified as street and filled with address1 rather than address2. The address2 case is a behavior change introduced by the new exact-match street term — those fields previously matched nothing.

Code Review Details
  • ⚠️ : New exact street term address also matches address2/Address 2 after digit stripping, classifying extended-address fields as street
    • app/src/main/kotlin/com/x8bit/bitwarden/data/autofill/util/ViewStructureUtils.kt:225
  • ⚠️ : Extended check runs after the street check, and addressLine2 digit-strips to the street term addressline, so the extended heuristic never fires for the two most common line-2 field names
    • app/src/main/kotlin/com/x8bit/bitwarden/data/autofill/util/ViewNodeExtensions.kt:195

Comment on lines +225 to +227
val SUPPORTED_EXACT_ADDRESS_STREET_HINTS: List<String> = listOf(
"address",
)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ IMPORTANT: address2 normalizes to address, so line-2 fields exact-match as street.

Details and fix

equalsAnyTerms compares the output of toLowerCaseAndStripNonAlpha(), which strips digits (replace(Regex("[^a-z]"), "")). An attribute value of address2 / address_2, or a label of Address 2, therefore normalizes to exactly address and matches this term.

Trace, for <input name="address2"> on a form with no autocomplete attribute — the case this exact term was added for:

  1. hints() returns ["address2", ...] (name is in SUPPORTED_HTML_ATTRIBUTE_HINTS).
  2. HtmlInfo.isAddressStreetField()equalsAnyTerms(["address"])true.
  3. supportedAutofillHint evaluates isAddressStreetField (ViewNodeExtensions.kt:191) before isAddressExtendedField (line 195), so the field resolves to ADDRESS_STREET.
  4. FilledDataBuilderImpl.kt:287 fills the apartment/suite field with address1.

Before this change that field matched nothing and was left alone, so this turns a miss into a wrong value.

Exact-matching against a digit-preserving normalization (lowercase + strip non-alphanumeric) would keep address working while leaving address2 unmatched.

this.isAddressLocalityField -> AutofillHint.Identity.ADDRESS_LOCALITY
this.isAddressRegionField -> AutofillHint.Identity.ADDRESS_REGION
this.isAddressCountryField -> AutofillHint.Identity.ADDRESS_COUNTRY
this.isAddressExtendedField -> AutofillHint.Identity.ADDRESS_EXTENDED

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ IMPORTANT: addressLine2 is claimed by the street heuristic, so this branch never sees it.

Details and fix

SUPPORTED_RAW_ADDRESS_STREET_HINTS contains addressline, and digit stripping collapses addressLine2 / address_line_2 / addressLine1 all to addressline. Since isAddressStreetField is evaluated at line 191, before this branch, an id/hint/HTML name of addressLine2 resolves to ADDRESS_STREET and gets filled with address1.

SUPPORTED_RAW_ADDRESS_EXTENDED_HINTS only holds addressext, so addressLine2 and address2 — the two most common line-2 field names on real forms — never reach AddressExtended by heuristic at all. The address-line2 OS hint path does work; only the heuristic path in the PR objective is affected.

The fix needs both halves:

  • Match extended terms against a normalization that preserves digits, so addressline2 is distinguishable from addressline1 (see the related comment on SUPPORTED_EXACT_ADDRESS_STREET_HINTS).
  • Move this.isAddressExtendedField above this.isAddressStreetField so the more specific term wins when both could match.

@codecov

codecov Bot commented Sep 9, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 69.23077% with 8 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (PM-41294/identity-autofill-multi-partition-pipeline@7bcecc9). Learn more about missing BASE report.

Files with missing lines Patch % Lines
...bitwarden/data/autofill/util/ViewNodeExtensions.kt 58.33% 2 Missing and 3 partials ⚠️
...twarden/data/autofill/parser/AutofillParserImpl.kt 0.00% 1 Missing ⚠️
...arden/data/autofill/util/AutofillViewExtensions.kt 0.00% 0 Missing and 1 partial ⚠️
...bitwarden/data/autofill/util/HtmlInfoExtensions.kt 80.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@                                  Coverage Diff                                   @@
##             PM-41294/identity-autofill-multi-partition-pipeline    #7371   +/-   ##
======================================================================================
  Coverage                                                       ?   85.77%           
======================================================================================
  Files                                                          ?     1056           
  Lines                                                          ?    69259           
  Branches                                                       ?    10330           
======================================================================================
  Hits                                                           ?    59409           
  Misses                                                         ?     6225           
  Partials                                                       ?     3625           
Flag Coverage Δ
app-data 18.68% <69.23%> (?)
app-ui-auth-tools 19.04% <0.00%> (?)
app-ui-platform 16.81% <0.00%> (?)
app-ui-vault 27.59% <0.00%> (?)
authenticator 5.99% <0.00%> (?)
lib-core-network-bridge 4.04% <0.00%> (?)
lib-data-ui 1.18% <0.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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

Labels

ai-review Request a Claude code review app:password-manager Bitwarden Password Manager app context t:feature Change Type - Feature Development

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant