Skip to content

PIR: Forward extras on extracted profiles - #9353

Open
noisysocks wants to merge 1 commit into
developfrom
randerson/pir-extras-passthrough
Open

PIR: Forward extras on extracted profiles#9353
noisysocks wants to merge 1 commit into
developfrom
randerson/pir-extras-passthrough

Conversation

@noisysocks

@noisysocks noisysocks commented Jul 31, 2026

Copy link
Copy Markdown
Collaborator

Task/Issue URL:
https://app.asana.com/1/137249556945/task/1216773212741753
Tech Design URL (if applicable):
https://app.asana.com/1/137249556945/project/481882893211075/task/1216773212741757
API Proposals URL(s) (if applicable):

Description

Support extras in extracted profiles and addresses, pass them along to fillForm, and update stored profiles with the freshly scraped profile. This lessens the need for an app release when an opt out form requires a new field we don't have.

Steps to test this PR

  1. Point C-S-S to Support extracting extras from profiles and addresses content-scope-scripts#2907:
npm install @duckduckgo/content-scope-scripts@github:duckduckgo/content-scope-scripts#pr-releases/randerson/pir-extras-open-field
  1. Build and run.
  2. Open Settings → Pir Dev Settings → Broker Config.
  3. Select cyberbackgroundchecks.com and replace the JSON with: https://dub.duckduckgo.com/duckduckgo/dbp-api/blob/2fb2bb29f5d3f67bc6c70098ca36db7ca4a100b9/dbp-json/data/json/cyberbackgroundchecks.com.json
  4. Complete a scan and opt out: Debug Scan → Run opt out → PIR Email → Debug opt out.
  5. The street and zip fields in the post-confirmation opt out form should be filled from data that was extracted during the scan.

Note

Medium Risk
Touches encrypted PIR local storage and changes scan persistence from insert-only to insert-or-update, which affects opt-out data continuity; migration is auto-generated with a dedicated test.

Overview
Adds extras maps on extracted profiles and addresses so broker configs can scrape fields outside the native schema and pass them into opt-out fillForm without an app release.

Persistence: Room v17 adds an extras column (default {}) on pir_extracted_profiles, with Moshi converters for Map<String, String>. saveExtractedProfiles replaces saveNewExtractedProfiles: new rows insert as before; matching rows are updated via refreshedWith, keeping local id, date added, and deprecated flag while merging profile and per-address extras (scraped keys win; missing keys retain stored values).

Pipeline: Scan success maps script extras onto models; toParams forwards age, addresses, phones, relatives, identifier, and extras to C-S-S. Profile identity comparisons (matches, job-record keys) ignore address extras so new scraped fields do not create duplicate records.

Tests: Room migration 16→17, repository refresh/merge behavior, and PirUtils helpers; dev results UI shows extras.

Reviewed by Cursor Bugbot for commit 38f5db8. Bugbot is set up for automated code reviews on this repo. Configure here.

Adds an open extras map to extracted profiles and to their addresses. Native
never looks inside it: it reads extras off the extract message, stores them,
and hands them back verbatim when an opt-out form is filled. A new field can
then be added in the broker config alone, rather than needing a change and a
release on all three platforms.

- Parse profile-level and address-level extras from the extract response,
  strictly as Map<String, String>, so malformed values fail loudly through the
  existing message-parsing error path.
- Persist them: new extras column on pir_extracted_profiles via a v17 auto
  migration, with address extras carried inside the existing addresses JSON.
- Send addresses, extras, age, phoneNumbers, relatives and identifier to
  fillForm. Previously only name, profileUrl, fullName and email were sent, so
  addresses were dropped entirely.
- Refresh stored profiles on re-scan rather than ignoring them. Extras are
  merged, so a key missing from a later scrape keeps the value already stored
  and a pending opt-out doesn't lose fields when a broker changes its markup.
- Exclude extras from profile identity comparisons, so shipping a config that
  starts scraping a new field cannot make stored records look removed.

Tech design:
https://app.asana.com/1/137249556945/project/481882893211075/task/1216773212741757

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@noisysocks
noisysocks force-pushed the randerson/pir-extras-passthrough branch from 5b4c506 to 38f5db8 Compare August 3, 2026 05:03
@noisysocks noisysocks changed the title PIR: Preserve and forward broker-supplied profile fields native doesn't model PIR: Forward extras on extracted profiles Aug 3, 2026
@noisysocks
noisysocks marked this pull request as ready for review August 3, 2026 05:10
@noisysocks
noisysocks requested a review from landomen August 3, 2026 05:11

This comment was marked as low quality.

This comment was marked as low quality.

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.

1 participant