Skip to content

fix: add maxLength to contact inputs (#72)#171

Open
Emins25 wants to merge 1 commit intoPi-Defi-world:mainfrom
Emins25:codex/acbu-72-20260408
Open

fix: add maxLength to contact inputs (#72)#171
Emins25 wants to merge 1 commit intoPi-Defi-world:mainfrom
Emins25:codex/acbu-72-20260408

Conversation

@Emins25
Copy link
Copy Markdown
Contributor

@Emins25 Emins25 commented Apr 8, 2026

Summary

  • add explicit maxLength limits to the contacts alias and pay URI inputs
  • keep the limits generous enough for normal aliases and Stellar pay URI/address values while preventing unbounded input

Testing

  • npm run build (fails due pre-existing unrelated parse errors in app/(app)/lending/page.tsx:725 and app/(app)/send/page.tsx:203)

Summary by CodeRabbit

  • Bug Fixes
    • Added input length constraints to the contacts settings form. Alias field is now limited to 64 characters and pay URI/address field to 256 characters, preventing users from entering excessively long values.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 8, 2026

📝 Walkthrough

Walkthrough

This pull request adds input length constraints to form fields in the contact settings page by introducing two local constants (ALIAS_MAX_LENGTH at 64 characters and PAY_URI_MAX_LENGTH at 256 characters) and applying them as maxLength props to the corresponding input fields.

Changes

Cohort / File(s) Summary
Input Field Constraints
app/(app)/me/settings/contacts/page.tsx
Added local constants for max length values and applied maxLength props to alias and pay URI input fields to enforce UI-level input limits.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Possibly related issues

  • #72: Directly addresses the issue by adding maxLength props to the alias and pay URI/address input fields in the contact settings page.

Poem

🐰 A rabbit hops through text so long,
With boundaries now, nothing goes wrong!
Sixty-four here, two-fifty-six there,
Input fields dance with limits to spare! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix: add maxLength to contact inputs' accurately describes the main change—adding maxLength constraints to contact input fields, as confirmed by the file changes and PR objectives.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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 and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@app/`(app)/me/settings/contacts/page.tsx:
- Around line 95-108: handleAdd currently relies only on input maxLength but
still posts whatever state holds; add a defensive submit-time validation inside
the handleAdd function to check addAlias.length <= ALIAS_MAX_LENGTH and
addPayUri.length <= PAY_URI_MAX_LENGTH before calling postContact. If either
check fails, prevent submission (return early) and surface a user-friendly error
(e.g., set an error state or show a toast) so invalid values are not sent to
postContact; keep the checks aligned to the existing ALIAS_MAX_LENGTH and
PAY_URI_MAX_LENGTH constants and update any existing error handling/state used
for other form errors.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 178165a7-ce32-43c1-9bd2-4e29de80bf3b

📥 Commits

Reviewing files that changed from the base of the PR and between fdffdb8 and 8496bb7.

📒 Files selected for processing (1)
  • app/(app)/me/settings/contacts/page.tsx

Comment on lines +95 to +108
<Input
placeholder="Alias"
value={addAlias}
maxLength={ALIAS_MAX_LENGTH}
onChange={(e: React.ChangeEvent<HTMLInputElement>) => setAddAlias(e.target.value)}
className="border-border"
/>
<Input
placeholder="Pay URI or address"
value={addPayUri}
maxLength={PAY_URI_MAX_LENGTH}
onChange={(e: React.ChangeEvent<HTMLInputElement>) => setAddPayUri(e.target.value)}
className="border-border"
/>
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Add submit-time length validation (not only input-level maxLength).

maxLength here is a good UI constraint, but handleAdd still posts whatever state contains. Add a defensive check before postContact so constraints are enforced at submit time too (and aligned with your “prevent unbounded input” objective).

💡 Suggested patch
 const handleAdd = async (e: React.FormEvent) => {
   e.preventDefault();
-  if (!addAlias.trim() && !addPayUri.trim()) return;
+  const alias = addAlias.trim();
+  const payUri = addPayUri.trim();
+  if (!alias && !payUri) return;
+  if (alias.length > ALIAS_MAX_LENGTH || payUri.length > PAY_URI_MAX_LENGTH) {
+    setError(`Alias must be <= ${ALIAS_MAX_LENGTH} and Pay URI/address must be <= ${PAY_URI_MAX_LENGTH} characters.`);
+    return;
+  }
   setAdding(true);
   setError('');
   try {
-    await userApi.postContact({ alias: addAlias.trim() || undefined, pay_uri: addPayUri.trim() || undefined }, opts);
+    await userApi.postContact({ alias: alias || undefined, pay_uri: payUri || undefined }, opts);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@app/`(app)/me/settings/contacts/page.tsx around lines 95 - 108, handleAdd
currently relies only on input maxLength but still posts whatever state holds;
add a defensive submit-time validation inside the handleAdd function to check
addAlias.length <= ALIAS_MAX_LENGTH and addPayUri.length <= PAY_URI_MAX_LENGTH
before calling postContact. If either check fails, prevent submission (return
early) and surface a user-friendly error (e.g., set an error state or show a
toast) so invalid values are not sent to postContact; keep the checks aligned to
the existing ALIAS_MAX_LENGTH and PAY_URI_MAX_LENGTH constants and update any
existing error handling/state used for other form errors.

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