Closed Bug 2071827 Opened 2 months ago Closed 2 months ago

Rust address store returns a `country` the JSON store hides on read, so migrated records gain a suppressed country code

Categories

(Toolkit :: Form Autofill, defect)

Firefox 157
defect

Tracking

()

RESOLVED FIXED
158 Branch
Tracking Status
firefox158 --- fixed

People

(Reporter: dimi, Assigned: dimi)

References

(Blocks 1 open bug)

Details

Attachments

(1 external file, 1 obsolete file)

The address JSON->Rust migration reports a record-level divergence on 0.12% of copied records, and every one of them is the same shape: the Rust store came back holding a country the JSON store did not report.

On nightly, 2026-09-07 through 2026-09-13, over both 157 and 158:

157 158
to_rust runs / clients 35,414 / 35,205 5,987 / 5,915
records copied (runs with source_total > 0) 42,112 7,389
diverged records 49 8
of those, added: country and nothing else 49 8
changed / dropped fields 0 / 0 0 / 0
records_lost 0 0

36 clients in total. None of the diverging runs failed; all reported result = ok.

Source: the address-rust-migration dashboard on sql.telemetry.mozilla.org, section 3 Fidelity, data through 2026-09-13.

Cause

AddressesBase._recordReadProcessor (toolkit/components/formautofill/FormAutofillStorageBase.sys.mjs:1506) deletes country and country-name from every record the JSON store hands out when the stored code is not in FormAutofill.countries, i.e. the set of codes that have bundled address metadata (AddressMetaDataLoader.getCountries()). The filter runs on read only; the record on disk keeps its country.

AddressStorageMigrator copies from the raw rows (source._data ?? (await source.getAll())), so the Rust store legitimately ends up holding the stored country. But #verify reads the source back through source.getAll(), which is filtered. country is a stored field so it is compared; country-name is derived and excluded by isStoredAddressField. Hence added: country and nothing else.

Two things follow, and they want separating:

  1. The divergence signal is a measurement artifact. Nothing was lost - dropped and records_lost are both 0 - and the copy is in fact more faithful to what is on disk than the baseline it is being checked against.

  2. The behaviour difference underneath is real. RustAutofillAddressStorage has no equivalent of _recordReadProcessor, so once a profile is on the Rust store those 57 records start exposing a country code with no address metadata behind it, where the JSON store suppressed it. Whatever the read filter protects - address capture, the country dropdown, country-name computation - stops being protected at migration.

Suggested fix

Apply the same unsupported-country filter on the Rust adapter's read path. That restores the pre-migration behaviour for these records and makes the fidelity check agree as a side effect.

The alternative - deciding the filter is obsolete and removing it from the JSON store too - also makes both sides agree, but changes behaviour for every profile still on JSON, so it should be its own bug if anyone wants it.

AddressesBase._recordReadProcessor deletes country and country-name from every
record the JSON store hands out when the stored code is absent from
FormAutofill.countries, the codes with bundled address metadata. The record on
disk keeps the code; only the read hides it.

RustAutofillAddressesAdapter had no equivalent, so a profile that migrated
started exposing a code the JSON store had suppressed. The same asymmetry
produced the migration's added: country divergence reports:
AddressStorageMigrator copies from the raw rows but verified against the
filtered read, so a copy was reported unfaithful for holding what is on disk.

Apply the rule in RustAutofillAddressesAdapter._recordFromRust, after the
derived fields are computed, so the telephone and street components are still
derived from the stored code as they are in the JSON store, which computes them
at write time.

A store that hides a stored field on read cannot be copied out of through that
read: the field would be written out of existence on the other side, which the
copy back to JSON does for a record only Rust holds. getAll() therefore takes
rawData, matching the JSON collection, and the migrator's copy step reads that
way while its verification keeps comparing the reads a consumer gets.

AddressesBase._recordReadProcessor deletes country and country-name from every
record the JSON store hands out when the code is absent from
FormAutofill.countries. The code stays on disk; only the read hides it.
RustAutofillAddressesAdapter had no equivalent, so a migrated profile started
exposing a code the JSON store suppressed, and the migration reported
added: country for comparing a copy of the raw rows against the filtered read.

Apply the same rule in _recordFromRust, after the derived fields are computed,
so the telephone and street components still come from the stored code as they
do in the JSON store.

A store that hides a field on read cannot be copied out of through that read:
the copy back would write the code out of existence for a record only Rust
holds. getAll() therefore takes rawData, matching the JSON collection, and the
copy step uses it while the verification keeps comparing the reads a consumer
gets.

Pushed by dlee@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/66df203037a9 https://hg.mozilla.org/integration/autoland/rev/469bd8dc80b5 Hide a country code with no address metadata on the Rust address store's read path. r=credential-management-reviewers,NeilDeakin
Status: ASSIGNED → RESOLVED
Closed: 2 months ago
Resolution: --- → FIXED
Target Milestone: --- → 158 Branch
Attachment #9641918 - Attachment is obsolete: true
QA Whiteboard: [qa-triage-done-c159/b158]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: