Skip to content

fix(pix): canonicalize +55 phone keys that already carry a + prefix#2240

Merged
Hugo0 merged 1 commit into
devfrom
fix/pix-phone-canonicalization
Jun 17, 2026
Merged

fix(pix): canonicalize +55 phone keys that already carry a + prefix#2240
Hugo0 merged 1 commit into
devfrom
fix/pix-phone-canonicalization

Conversation

@Hugo0

@Hugo0 Hugo0 commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

From the release-PR (#2236) CodeRabbit triage. normalizePixPhoneNumber returned the raw input when the cleaned value already started with +, so +55-11-99999-9999 kept its separators → non-canonical PIX key (risking key-match failures). Now always returns the separator-free +55 form. Adds the separator-with-+ regression cases (the existing +-prefix tests had no separators, so they never caught it). Non-phone inputs unchanged.

normalizePixPhoneNumber returned the raw input untouched when the cleaned value
already started with '+', so '+55-11-99999-9999' kept its separators and stayed
non-canonical — conflicting with the helper's contract and risking PIX-key
mismatches. Always return the separator-free +55 form. From release-PR #2236
CodeRabbit triage; adds the separator-with-+ regression cases the existing
+-prefix tests never exercised.
@vercel

vercel Bot commented Jun 17, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
peanut-wallet Ready Ready Preview, Comment Jun 17, 2026 8:41pm

Request Review

@coderabbitai

coderabbitai Bot commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 63e81925-3216-449b-b202-4de515092371

📥 Commits

Reviewing files that changed from the base of the PR and between 2a64883 and 82563a7.

📒 Files selected for processing (2)
  • src/utils/__tests__/withdraw.utils.test.ts
  • src/utils/withdraw.utils.ts

Walkthrough

normalizePixPhoneNumber is updated so that when the cleaned value is a valid PIX phone number, it always returns the separator-free canonical form—even if the raw input already started with +. Two new parametrized test cases verify that hyphens and spaces are stripped from inputs that carry a leading + prefix.

Changes

PIX Phone Number Normalization Fix

Layer / File(s) Summary
Strip separators from prefixed PIX phone inputs
src/utils/withdraw.utils.ts, src/utils/__tests__/withdraw.utils.test.ts
normalizePixPhoneNumber control flow revised: early-return of the raw pixKey is now guarded to non-phone keys only; for valid phone numbers, the cleaned (separator-free) value is always returned. Two new test cases assert the corrected behavior for +-prefixed inputs containing - and space separators.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically summarizes the main fix: canonicalizing PIX phone numbers that already have a + prefix by removing separators.
Description check ✅ Passed The description is directly related to the changeset, explaining the bug fix, the specific issue with +55 phone numbers with separators, and the regression tests added.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions

Copy link
Copy Markdown
Contributor

Code-analysis diff

Painscore total: 5798.03 → 5798.18 (+0.15)
Findings: 0 net (+3 new, -3 resolved)

🆕 New findings (3)

  • critical complexity — src/utils/withdraw.utils.ts — CC 63, MI 53.38, SLOC 229
  • medium high-mdd — src/utils/withdraw.utils.ts:248 — validatePixKey: MDD 22.4 (uses across many lines from declarations)
  • medium method-complexity — src/utils/withdraw.utils.ts:248 — CC 16 SLOC 61

✅ Resolved (3)

  • src/utils/withdraw.utils.ts — CC 63, MI 53.39, SLOC 229
  • src/utils/withdraw.utils.ts:247 — validatePixKey: MDD 22.4 (uses across many lines from declarations)
  • src/utils/withdraw.utils.ts:247 — CC 16 SLOC 61

@github-actions

Copy link
Copy Markdown
Contributor

🧪 UI test report — ✅ all green

Suites

  • unit: 1456 ran, 0 failed, 0 skipped, 19.6s

📊 Coverage (unit)

metric %
statements 52.4%
branches 34.8%
functions 39.5%
lines 52.3%
⏱ 10 slowest test cases
time test
0.4s src/components/Card/share-asset/__tests__/shareAssetLayout.test.ts › every stamp stays within canvas at any count
0.2s src/app/actions/__tests__/api-headers-extended.test.ts › should not include apiKey in updateUserById body
0.2s src/app/actions/__tests__/api-headers.test.ts › should include Content-Type in updateUserById
0.1s src/components/Global/GeneralRecipientInput/__tests__/GeneralRecipientInput.test.tsx › should handle valid 9-digit US account
0.1s src/app/(mobile-ui)/qr-pay/__tests__/qr-pay-states.test.tsx › Manteca PIX form ready shows merchant card + amount input + pay button
0.1s src/components/Global/GeneralRecipientInput/__tests__/GeneralRecipientInput.test.tsx › should handle too long for US account
0.1s src/components/Global/GeneralRecipientInput/__tests__/GeneralRecipientInput.test.tsx › should handle invalid ETH address (missing 0x prefix)
0.1s src/components/Global/GeneralRecipientInput/__tests__/GeneralRecipientInput.test.tsx › should handle maximum length (17 digits) US account
0.1s src/components/Global/GeneralRecipientInput/__tests__/GeneralRecipientInput.test.tsx › should handle valid German IBAN
0.1s src/components/Global/GeneralRecipientInput/__tests__/GeneralRecipientInput.test.tsx › should handle valid ETH address
📍 Inline annotations are in the **Unit test report** check above. Coverage artifact: `coverage-unit`. Generated by `.github/workflows/tests.yml`.

@Hugo0 Hugo0 marked this pull request as ready for review June 17, 2026 20:44
@Hugo0 Hugo0 merged commit 75f6aa4 into dev Jun 17, 2026
18 of 20 checks passed
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