← all branches

fix/rpu-12-digit

safeviewing older commit
20aa256 · incrementalPR #246reviewed 2026-07-05 21:14 UTC0H · 0M · 2L · 5I
The branch
Purpose
Fix blank toast description + frozen 'Creando…' state when an RPU shorter than 12 digits is submitted on the new-contract drawer
Goal
Gate lookup and create on a complete 12-digit RPU (isValidRpu), surface the real server rejection reason instead of a blank toast, and ensure paste of a formatted RPU works correctly
Sub-goals
  • SG-1: Extract RPU_LENGTH constant and validation helpers into rpu-errors.ts (single source of truth)
  • SG-2: Gate AddContractDrawer lookup + create-form reveal on isValidRpu (root cause fix)
  • SG-3: Add InlineContractForm client-side guard + extractServerErrorMessage for descriptive toasts
  • SG-4: Remove maxLength from the RPU input — browser applies it before onChange, truncating pasted formatted RPUs
  • SG-5: Add unit + component tests (9 unit + RPU gate + form error surfacing)
The changes (whole branch)
What
This incremental commit (SG-4 polish): imports RPU_LENGTH constant to replace three hardcoded 12s in AddContractDrawer, and removes maxLength={12} from the RPU text input with an explanatory comment
Why
maxLength is applied by the browser BEFORE onChange fires — a pasted '123 456 789 012' (15 chars) would be truncated to 12 characters including spaces, stripping digits and making paste-completion impossible
Areas
apps/platform/src/app/[locale]/(dashboard)/bills/_components+4112apps/platform/src/app/[locale]/(dashboard)/bills/_lib+1740apps/platform/src/messages+62
Blast
8 files, +468/−24 across bills UI, bills lib, and i18n messages. Frontend-only — no API, schema, or infra changes.
frontend-only no-backend-changes tests-added
CI checks· check-runs API not accessible via this tokenCodeRabbit· no .coderabbit.yaml in repo

Findings · 2

correctness1

low

Autofill/extension bypass of normalizeRpuInput

apps/platform/src/app/[locale]/(dashboard)/bills/_components/AddContractDrawer.tsx

If a browser autofill or extension sets the value without firing a synthetic onChange, normalizeRpuInput is bypassed and the cap update never runs. maxLength was a defense-in-depth against this. Not a regression — isValidRpu still gates lookup and submission; an over-long value would fail validation rather than cause a stuck 'Verificando…' state.

conventions1

low

`RPU_LENGTH - 1` comparator is marginally less scannable than literal `11`

apps/platform/src/app/[locale]/(dashboard)/bills/_components/AddContractDrawer.tsx:389

The expression `digits.length === RPU_LENGTH - 1` requires a mental subtraction to verify the plural boundary. The literal `11` was self-documenting. The constant form stays correct if RPU_LENGTH ever changes, so it is an acceptable trade-off — not a blocker.

History · 6 commits

  1. 427115eneeds attentionincremental0H · 1M · 3L2026-07-05 21:43
  2. c6ce7d8needs attentionincremental0H · 3M · 6L2026-07-05 21:35
  3. d8cbd91needs attentionincremental0H · 0M · 3L2026-07-05 21:25
  4. 20aa256safeincremental0H · 0M · 2L2026-07-05 21:14current
  5. 77a5d70needs attentionincremental0H · 2M · 9L2026-07-05 21:09
  6. 586531aneeds attentionfull0H · 5M · 10L2026-07-05 20:51