8000 Create link error message and bug fix by marcusljf · Pull Request #2609 · dubinc/dub · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Create link error message and bug fix #2609

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

marcusljf
Copy link
Collaborator
@marcusljf marcusljf commen 8000 ted Jul 4, 2025

Changed the error message from "Invalid key" to "Enter a valid short link".

Found a bug that the destination URL allowed spaces, and then those links went to 404 pages. So now it shows an error if the user tries to create a short link with spaces in the destination url.

Summary by CodeRabbit

  • Bug Fixes

    • Improved URL input validation to prevent whitespace characters in relevant forms.
    • Enhanced error messaging for invalid short link entries, providing clearer guidance to users.
  • Style

    • Minor code cleanup for better readability (no impact on functionality).

Changed the error message from "Invalid key" to "Enter a valid short link".

Found a bug that the destination URL allowed spaces, and then those links went to 404 pages. So now it shows an error if the user tries to create a short link with spaces in the destination url.
Copy link
Contributor
coderabbitai bot commented Jul 4, 2025

Walkthrough

Whitespace validation for URL input fields was introduced across several components. The logic now checks for whitespace in URL values, displaying error messages if invalid input is detected. Error handling in the partner link modal was refined to provide more user-friendly feedback for specific error cases. No changes were made to exported entity signatures.

Changes

File(s) Change Summary
apps/web/ui/links/destination-url-input.tsx Removed an unnecessary blank line in the onChange handler; no logic or structural changes made.
apps/web/ui/links/link-builder/controls/link-builder-destination-url-input.tsx Added whitespace validation for URL input; sets/clears errors accordingly in the onChange handler.
apps/web/ui/partners/add-partner-link-modal.tsx Added whitespace validation for URL input; improved error handling and user feedback for form errors.

Suggested reviewers

  • steven-tey

Poem

A hop, a skip, a check for space,
URLs now must know their place.
If whitespace sneaks into the field,
A friendly error is revealed.
Forms are smarter, errors clear—
The code is tidy, spring is here!
🐇✨

✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
vercel bot commented Jul 4, 2025

@marcusljf is attempting to deploy a commit to the Dub Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Contributor
@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: 0

🧹 Nitpick comments (1)
apps/web/ui/partners/add-partner-link-modal.tsx (1)

43-43: Remove unused form methods from destructuring.

The setError and clearErrors methods are extracted from useForm but never used in the component. Since validation is handled through the register function's validate option, these can be removed.

Apply this diff to clean up the unused destructuring:

-const { register, handleSubmit, watch, setError, clearErrors, formState } = useForm<FormData>({
+const { register, handleSubmit, watch, formState } = useForm<FormData>({
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9a9811a and f10aef7.

📒 Files selected for processing (3)
  • apps/web/ui/links/destination-url-input.tsx (0 hunks)
  • apps/web/ui/links/link-builder/controls/link-builder-destination-url-input.tsx (2 hunks)
  • apps/web/ui/partners/add-partner-link-modal.tsx (4 hunks)
💤 Files with no reviewable changes (1)
  • apps/web/ui/links/destination-url-input.tsx
🧰 Additional context used
🧠 Learnings (1)
apps/web/ui/partners/add-partner-link-modal.tsx (1)
Learnt from: TWilson023
PR: dubinc/dub#2471
File: apps/web/ui/auth/reset-password-form.tsx:52-65
Timestamp: 2025-06-04T15:09:51.562Z
Learning: In the Dub codebase, server-side validation errors for password fields are handled via toast notifications rather than using react-hook-form's setError method to display field-specific errors. This architectural pattern separates client-side validation feedback (inline) from server-side error handling (toast).
🧬 Code Graph Analysis (1)
apps/web/ui/links/link-builder/controls/link-builder-destination-url-input.tsx (1)
apps/web/ui/links/link-builder/link-builder-provider.tsx (1)
  • LinkFormData (13-13)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build
🔇 Additional comments (5)
apps/web/ui/links/link-builder/controls/link-builder-destination-url-input.tsx (2)

20-20: LGTM: Proper addition of setError for validation.

The addition of setError to the form context destructuring is necessary for the new validation logic.


45-51: LGTM: Effective real-time URL validation implementation.

The validation logic correctly prevents URLs with whitespace characters, which addresses the bug mentioned in the PR objectives. The real-time validation provides immediate feedback to users, improving the user experience.

The regex /\s/ appropriately catches all whitespace characters, and the error handling properly uses react-hook-form's setError and clearErrors methods.

apps/web/ui/partners/add-partner-link-modal.tsx (3)

94-98: LGTM: Excellent improvement to error message handling.

The error handling now properly catches the specific "Invalid key." error and replaces it with the more user-friendly "Enter a valid short link" message, which directly addresses one of the PR objectives. The fallback logic is also well-structured.


196-202: LGTM: Consistent URL validation implementation.

The validation logic correctly prevents URLs with whitespace characters, consistent with the validation added to the other component. Using react-hook-form's validate option is appropriate for this use case.


221-225: LGTM: Proper error display for URL validation.

The error display correctly shows validation errors for the URL field, providing users with clear feedback when their input contains invalid characters.

Copy link
vercel bot commented Jul 4, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
dub ✅ Ready (Inspect) Visit Preview Jul 4, 2025 5:33am

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.

2 participants
0