Skip to content

fix: localize Pix key validation errors - #3103

Open
chip-peanut-bot[bot] wants to merge 1 commit into
devfrom
chip/localize-pix-validation-error
Open

chip-peanut-bot[bot] wants to merge 1 commit into
devfrom
chip/localize-pix-validation-error

Conversation

@chip-peanut-bot

Copy link
Copy Markdown
Contributor

Summary

  • render Pix key validation failures through the existing localized message catalog
  • add regression coverage for Portuguese and Latin American Spanish

Why

The Pix key screen exposed the validator's internal English message even when the app language was Portuguese or Spanish.

Verification

  • pnpm exec jest src/features/withdraw/views/__tests__/PixKeySendView.test.tsx src/i18n/app/__tests__/messages.test.ts --runInBand
  • pnpm exec eslint src/features/withdraw/views/PixKeySendView.tsx src/features/withdraw/views/__tests__/PixKeySendView.test.tsx
  • pnpm typecheck
  • pnpm prettier --check src/features/withdraw/views/PixKeySendView.tsx src/features/withdraw/views/__tests__/PixKeySendView.test.tsx

Requested by @abalindahttps://discord.com/channels/972435984954302464/1483085665930444944/1547653726704246835

@vercel

vercel Bot commented Sep 10, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated
peanut-wallet Ready Ready Preview Sep 10, 2026 5:29pm UTC

Request Review

@coderabbitai

coderabbitai Bot commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 4c4a16c3-0e98-42d2-b89d-4a5a27af1bef

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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.

❤️ Share

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

@github-actions

Copy link
Copy Markdown
Contributor

Code-analysis diff

Painscore total: 8994.43 → 8994.53 (+0.1)
Findings: 0 net (+2 new, -2 resolved)

🆕 New findings (2)

  • medium high-mdd — src/features/withdraw/views/PixKeySendView.tsx:24 — PixKeySendView: MDD 23.6 (uses across many lines from declarations)
  • medium complexity — src/features/withdraw/views/PixKeySendView.tsx — CC 12, MI 60.43, SLOC 53

✅ Resolved (2)

  • src/features/withdraw/views/PixKeySendView.tsx:24 — PixKeySendView: MDD 22.3 (uses across many lines from declarations)
  • src/features/withdraw/views/PixKeySendView.tsx — CC 12, MI 60.38, SLOC 53

@github-actions

Copy link
Copy Markdown
Contributor

🧪 UI test report — ✅ all green

Suites

  • unit: 7069 ran, 0 failed, 0 skipped, 1.9m

📊 Coverage (unit)

metric %
statements 77.1%
branches 63.5%
functions 71.0%
lines 78.1%
⏱ 10 slowest test cases
time test
🐢 9.0s src/app/(mobile-ui)/qr-pay/__tests__/qr-pay-states.test.tsx › Network failure keeps loading while retries remain, then shows the generic error
4.0s src/app/(mobile-ui)/qr-pay/__tests__/qr-pay-states.test.tsx › MANTECA_USER_NOT_PROVISIONED fails fast with copy that names the real cause
4.0s src/app/(mobile-ui)/qr-pay/__tests__/qr-pay-states.test.tsx › MANTECA_SOURCE_OVER_MONTHLY_CAP fails fast with copy that names the real cause
4.0s src/app/(mobile-ui)/qr-pay/__tests__/qr-pay-states.test.tsx › MANTECA_MERCHANT_RECENT_REFUND fails fast with copy that names the real cause
4.0s src/app/(mobile-ui)/qr-pay/__tests__/qr-pay-states.test.tsx › a refused idempotency key tells the user to scan again, not to contact support
4.0s src/app/(mobile-ui)/qr-pay/__tests__/qr-pay-states.test.tsx › routes the KYC rejection on its wire code, and does not retry it
4.0s src/app/(mobile-ui)/qr-pay/__tests__/qr-pay-states.test.tsx › User KYC not approved fails fast with copy that names the real cause
4.0s src/app/(mobile-ui)/qr-pay/__tests__/qr-pay-states.test.tsx › MANTECA_MERCHANT_VOLUME_NEAR_CAP fails fast with copy that names the real cause
3.0s src/app/(mobile-ui)/qr-pay/__tests__/qr-pay-states.test.tsx › Scan that recovers on the retry lands on the payment screen, not an error
3.0s src/app/(mobile-ui)/qr-pay/__tests__/qr-pay-states.test.tsx › Going offline blames the connection, and reconnecting clears it for the recovered scan
📍 Inline annotations are in the **Unit test report** check above. Coverage artifact: `coverage-unit`. Generated by `.github/workflows/tests.yml`.

@chip-peanut-bot chip-peanut-bot Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Chip review — no blocking findings — this is not an approval

The Pix key screen now consistently renders validation failures through the selected locale, with focused Portuguese and Latin American Spanish regression coverage. No actionable defects found.

Findings

  • MINOR · src/features/withdraw/views/PixKeySendView.tsx:38 · [claude-opus] Pasted PIX Automático code now says only "Invalid Pix key"
    validatePixKey returns a deliberately specific message for recurring codes — PIX Automático (recurring) codes are not supported (src/utils/withdraw.utils.ts:329, with a comment stating the intent that "every recurring shape gets the specific message instead of the generic one"). Dropping result.message means a user who pastes a recurring copia-e-cola into this view now only sees withdraw.pixKey.invalid ("Chave Pix inválida"), with no hint that the code type itself is unsupported and that a regular Pix QR is needed. Everywhere else the product does explain it: the scanner classifies these as EQrType.PIX_RECURRING and qr-pay renders the localized pixRecurring / titlePixRecurring copy (src/i18n/app/messages/en.json:1335, 3218-3221, src/features/payments/flows/qr-pay/useQrFailureCopy.ts:38). This is exactly the pattern tracked as an open problem in product truth — /home/chip/mono/product/feedback/problems/payment-error-copy-wrong-or-generic.md, whose lead evidence is "A single generic error message is shown for all PIX payment failure causes, hiding the real reason from the user". The code is what's wrong here, not the product doc. Fix: keep the localization but branch on the known case, e.g. setErrorMessage(isPixRecurringCode(normalized) ? tQr('errors.pixRecurring') : t('pixKey.invalid')), reusing the string that already exists in all three locale files.

Checked clean

  • Confirmed the detached worktree head, trusted author, dev base ref, base SHA, and merge base exactly match the supplied review pin.
  • Traced every validatePixKey failure through PixKeySendView and confirmed invalid inputs now use withdraw.pixKey.invalid while valid inputs and QR-pay routing are unchanged.
  • Verified pt-BR and es-419 contain localized invalid-key copy; es-AR inherits the es-419 value through the resolved catalog merge.
  • Reviewed ValidatedInput debounce, stale-validation, clear, and state-update behavior for regressions around the changed callback.
  • Exact-head unit, typecheck, eslint, format, native-export, CodeQL, and aggregate CI checks passed; the remaining bot-approval failure only awaits the human orderer's approval.
  • Local Jest execution was unavailable because this detached worktree has no installed Jest binary; exact-head CI unit coverage passed instead.

Security review: did not run — this change has no security, privacy or money surface, so it was not asked. This review is one reviewer short.

Third opinion by claude-opus: 1 finding(s), marked with the model name. It answers only product truth, missing tests and the cross-repo contract, so treat its findings as advice.

Exact head: 25ea5a5ed111 · Context: repo · Took 8m

@github-actions

Copy link
Copy Markdown
Contributor

🖼 Visual diff — 11 screens moved

15 of 74 shots changed · 59 identical · baseline 85f95e4 → head 25ea5a5

worst % screen widths
12.04% avatar-picker 320, 430
3.63% profile 320
0.07% home-avatar 320, 430
0.07% withdraw 320
0.03% add-money 430
0.03% home 430
0.03% identity-verification 430
0.03% settings-language 320, 430
0.03% withdraw-address-book 320, 430
0.01% kyc-action-required 320
0.01% withdraw-bank-form 320

job summary · before/after/diff images — artifact

Fixture screenshots, no backend. Advisory — this check never blocks a merge. Posted from the default branch by ds-shots-comment.yml; the report it renders is untrusted data.

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