MNTOR-5244: backfill stale primary_sha1 / email_addresses.sha1#6703
Merged
Conversation
Vinnl
approved these changes
Jun 4, 2026
Vinnl
left a comment
Collaborator
There was a problem hiding this comment.
Thanks! I don't think I have an easy way to get my local setup in a configuration that I can reproduce this, but nothing major jumped out to me from the code - though I think the suggestion about aborting when modifying more than one row might be good to implement still.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
References:
Jira: MNTOR-5244
Description
Subscribers who changed their email before the MNTOR-5219 fix (
ac7f41289, 2026-02-27) kept aprimary_sha1/email_addresses.sha1computed from their old email. Because the breach-alert notifier matches on these stored hashes while the dashboard re-hashes the user's current email and queries HIBP live, those users can receive a breach alert that never appears on their dashboard (surfaced in MNTOR-5286). MNTOR-5219 fixed this going forward but shipped no backfill.Measured impact on prod (2026-05-29):
subscribers.primary_sha1: 66,446 / 11,680,354 verified (0.57%)email_addresses.sha1: 11,906 / 2,770,362 verified (0.43%)This PR adds a one-off, batched, idempotent maintenance script that realigns each stored hash with
getSha1(lower(email)).Screenshot (if applicable)
Not applicable.
How to test
npm run test-integrations -- src/db/backfillStaleSha1.integration.ts— 4/4 pass: realigns stale verified rows, leaves correct rows untouched, skips unverified rows, idempotent on re-run, dry-run writes nothing; covers both tables.prettier --checkandeslintclean on new files;tscreports no errors in new files.node esbuild.cronjobs.jsemitsdist/scripts/cronjobs/backfillStaleSha1.js.npm run script:backfill-stale-sha1 -- --dry-run) reports stale counts matching the blast radius above (~66,446 primary / ~11,906 secondary).stale_primary = 0/stale_secondary = 0.Checklist (Definition of Done)