Repository navigation
Fold provider alias domains to a canonical form (googlemail.com, me.com, mac.com) - #26
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (5)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (4)
📝 WalkthroughWalkthroughProvider-specific alias domains are folded to canonical domains during normalization. Google maps ChangesProvider Domain Folding
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant Client
participant Normalizer
participant MailboxProvider
Client->>Normalizer: normalize email address
Normalizer->>MailboxProvider: resolve provider and canonical domain
MailboxProvider-->>Normalizer: canonical domain mapping
Normalizer-->>Client: normalized address and provider
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
tests/test_normalize.py (1)
153-163: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value
test_google_gmail_canonical_unchangedduplicates existingtest_google_consumer_gmail.Lines 124–134 (
test_google_consumer_gmail) and lines 153–163 (test_google_gmail_canonical_unchanged) are functionally identical — same UUID-with-periods local part, samegmail.comdomain, same MX records, same expected output. Only the docstrings differ. Consider removing the duplicate or differentiating the assertion (e.g., testing a non-period local part to specifically isolate the "no folding" behavior).🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tests/test_normalize.py` around lines 153 - 163, The test_google_gmail_canonical_unchanged case duplicates test_google_consumer_gmail. Remove the duplicate test, or change its input and expected assertion to uniquely verify that canonical gmail.com addresses are not folded, while preserving the existing Gmail normalization coverage.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@tests/test_normalize.py`:
- Around line 153-163: The test_google_gmail_canonical_unchanged case duplicates
test_google_consumer_gmail. Remove the duplicate test, or change its input and
expected assertion to uniquely verify that canonical gmail.com addresses are not
folded, while preserving the existing Gmail normalization coverage.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 4130e9b7-9473-42a2-85ec-bcfbb021d091
📒 Files selected for processing (5)
README.mdemail_normalize/__init__.pyemail_normalize/providers.pytests/test_normalize.pytests/test_normalizer.py
|
Addressed the CodeRabbit nitpick in 98bb587: |
googlemail.com now folds to gmail.com, and me.com/mac.com fold to icloud.com, so addresses that reach the same mailbox normalize to the same value. Aliasing is opt-in per provider via a new CanonicalDomains mapping, applied only to a provider's own consumer alias domains and never to custom domains that merely share MX servers. Domains that share a provider but are separate mailboxes (Microsoft outlook/hotmail, Yahoo yahoo/aol) are intentionally left unchanged.
test_google_gmail_canonical_unchanged used a period-laden local part, making it functionally identical to test_google_consumer_gmail — dot stripping masked whether the domain was actually folded. Use a plain local part (no periods, no plus) so the test verifies exactly one thing: gmail.com is the canonical Google domain and is never folded away. Verified via mutation (injecting a gmail.com fold now fails it).
98bb587 to
98e973f
Compare
- Fold provider alias domains to a canonical form (#25, #26): googlemail.com -> gmail.com, me.com/mac.com -> icloud.com. Domains that share a provider but are separate mailboxes (outlook.com/ hotmail.com, yahoo.com/aol.com) are intentionally left unchanged. - Update dependencies: pymdown-extensions (#27) Note: this changes normalized output for googlemail.com, me.com, and mac.com addresses, so stored normalized values may need recomputing. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Summary
Folds provider alias domains to a single canonical form during normalization, so that addresses which reach the same mailbox normalize to the same value:
googlemail.com→gmail.comme.com,mac.com→icloud.comFixes #25.
Approach
CanonicalDomainsmapping (Mapping[str, str], alias → canonical) onMailboxProvider, defaulting to an empty, immutableMappingProxyType. Populated forAppleandGoogleonly.Normalizer.normalizeapplies the fold after the existing local-part rules:StripPeriodDomainsguard added in Period stripping incorrectly applied to Google Workspace domains (only consumer Gmail should strip dots) #23 for Google Workspace.outlook.com/hotmail.com, Yahooyahoo.com/aol.com) are intentionally left unchanged, with tests locking that in.Tests
STRIP_PERIODS), and a negative test (hotmail.comnot folded).skip_dnsstatic-map tests for the same cases.NormalizerTestCasepattern) confirminggmail.com/googlemail.comcollapse to the same address.All 70 tests pass;
pre-commit(ruff format + ruff) clean; coverage 100% onproviders.py. README normalization-rules table updated with a Domain Folding column.Summary by CodeRabbit
googlemail.comnow normalizes togmail.com.me.comandmac.comnow normalize toicloud.com.hotmail.comvsoutlook.com) from collapsing.