Bug Fix: Fixed field should not allow only whitespace values issue
What does this PR do?
Added validation to check the Default Prefix is empty or contain whitespaces using .trim() method.
Fixes #2297
Type of change
- [x] Bug fix (non-breaking change which fixes an issue)
- [ ] Chore (refactoring code, technical debt, workflow improvements)
- [ ] Enhancement (small improvements)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [ ] This change requires a documentation update
How should this be tested?
- Navigate to Dashbaord -> APIs -> Select anyone API -> API Settings
- Enter only whitespace (e.g., several spaces) in the "Default Prefix" field.
- Attempt to save the changes.
- Check if the error message is showing in bottom right corner or not
Checklist
Required
- [x] Filled out the "How to test" section in this PR
- [x] Read Contributing Guide
- [x] Self-reviewed my own code
- [x] Commented on my code in hard-to-understand areas
- [x] Ran
pnpm build - [x] Ran
pnpm fmt - [x] Checked for warnings, there are none
- [x] Removed all
console.logs - [x] Merged the latest changes from main onto my branch with
git pull origin main - [x] My changes don't cause any responsiveness issues
Appreciated
- [ ] If a UI change was made: Added a screen recording or screenshots to this PR
- [ ] Updated the Unkey Docs if changes were necessary
Summary by CodeRabbit
-
New Features
- Enhanced input validation for the default prefix field to prevent submission of empty or whitespace-only values, with error messaging for users.
-
Bug Fixes
- Maintained existing validation checks to ensure robust handling of default prefix submissions.
⚠️ No Changeset found
Latest commit: 7ad275d084f424c551ecc8b062d9ce35dcd9b611
Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.
This PR includes no changesets
When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types
Click here to learn what changesets are, and how to add one.
Click here if you're a maintainer who wants to add a changeset to this PR
The latest updates on your projects. Learn more about Vercel for Git ↗︎
| Name | Status | Preview | Comments | Updated (UTC) |
|---|---|---|---|---|
| engineering | ✅ Ready (Inspect) | Visit Preview | 💬 Add feedback | Oct 13, 2024 6:53pm |
@vinod-techstax is attempting to deploy a commit to the Unkey Team on Vercel.
A member of the Team first needs to authorize it.
[!WARNING]
Rate limit exceeded
@chronark has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 18 minutes and 36 seconds before requesting another review.
⌛ How to resolve this issue?
After the wait time has elapsed, a review can be triggered using the
@coderabbitai reviewcommand as a PR comment. Alternatively, push new commits to this PR.We recommend that you space out your commits to avoid hitting the rate limit.
🚦 How do rate limits work?
CodeRabbit enforces hourly rate limits for each developer per organization.
Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.
Please see our FAQ for further information.
📥 Commits
Files that changed from the base of the PR and between 6e45634e8d530f45a9f96786990c44bb0b15caf5 and 7ad275d084f424c551ecc8b062d9ce35dcd9b611.
📝 Walkthrough
📝 Walkthrough
📝 Walkthrough
📝 Walkthrough
Walkthrough
The changes introduced in this pull request enhance the validation process for the DefaultPrefix component within the API settings. A new validation check has been added to the onSubmit function to ensure that the defaultPrefix value is not empty or composed solely of whitespace. If this condition is violated, an error toast is displayed, preventing the submission of invalid values.
Changes
| File Path | Change Summary |
|---|---|
| apps/dashboard/app/(app)/apis/[apiId]/settings/default-prefix.tsx | Added validation check in onSubmit for defaultPrefix to prevent submission of empty or whitespace-only values. Trigger error toast on violation. |
Assessment against linked issues
| Objective | Addressed | Explanation |
|---|---|---|
The Default Prefix field should not allow only whitespace values. (#2297) |
✅ |
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?
🪧 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.Generate unit testing code for this file.Open a follow-up GitHub issue for this discussion.
- Files and specific lines of code (under the "Files changed" tab): Tag
@coderabbitaiin a new review comment at the desired location with your query. Examples:@coderabbitai generate unit testing code for this file.@coderabbitai modularize this function.
- PR comments: Tag
@coderabbitaiin 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 generate unit testing code.@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.
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 pauseto pause the reviews on a PR.@coderabbitai resumeto resume the paused reviews.@coderabbitai reviewto trigger an incremental review. This is useful when automatic reviews are disabled for the repository.@coderabbitai full reviewto do a full review from scratch and review all the files again.@coderabbitai summaryto regenerate the summary of the PR.@coderabbitai resolveresolve all the CodeRabbit review comments.@coderabbitai configurationto show the current CodeRabbit configuration for the repository.@coderabbitai helpto get help.
Other keywords and placeholders
- Add
@coderabbitai ignoreanywhere in the PR description to prevent this PR from being reviewed. - Add
@coderabbitai summaryto generate the high-level summary at a specific location in the PR description. - Add
@coderabbitaianywhere in the PR title to generate the title automatically.
CodeRabbit Configuration File (.coderabbit.yaml)
- You can programmatically configure CodeRabbit by adding a
.coderabbit.yamlfile 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.
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
0 out of 2 committers have signed the CLA.
:x: Vinod-Mane3021
:x: vinod-techstax
You have signed the CLA already but the status is still pending? Let us recheck it.
Hey there and thank you for opening this pull request! 👋🏼
We require pull request titles to follow the Conventional Commits specification and it looks like your proposed title needs to be adjusted. Here is an example:
<type>[optional scope]: <description>
fix: I fixed something for Unkey
Details:
No release type found in pull request title "Bug Fix: Fixed field should not allow only whitespace values issue". Add a prefix to indicate what kind of release this pull request corresponds to. For reference, see https://www.conventionalcommits.org/
Available types:
- feat: A new feature
- fix: A bug fix
- docs: Documentation only changes
- style: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
- refactor: A code change that neither fixes a bug nor adds a feature
- perf: A code change that improves performance
- test: Adding missing tests or correcting existing tests
- build: Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm)
- ci: Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs)
- chore: Other changes that don't modify src or test files
- revert: Reverts a previous commit
/assign
Assigned to @DetrojaRadhey! Please open a draft PR linking this issue within 48h ⚠️ If we can't detect a PR from you linking this issue in 48h, you'll be unassigned automatically 🕹️ Excited to have you ship this 🚀
prefixes must not include any whitespace at all
I have applied validation for only Prefix = "" Prefix = " "
Do you mean validation for below also Prefix = "a " Prefix = " a"
yes,the validation must ensure there is no whitespace in the input field
@Vinod-Mane3021 I am not the maintainer of this repo. But like I commented on the issue. This issue also exists for the
https://app.unkey.com/apis/[api_123]/keys/[ks_123]/new
Currently your code only solves it for the default prefix.
cc: @chronark
@Vinod-Mane3021 I am not the maintainer of this repo. But like I commented on the issue. This issue also exists for the
https://app.unkey.com/apis/[api_123]/keys/[ks_123]/newCurrently your code only solves it for the default prefix.
cc: @chronark
in addition to that, we must also validate it on the serverside in the trpc handler.
ill make all changes
I have added validation for both
- Default prefix API Settings
- prefix in create api key
in both client and server side
can you review the changes @chronark
Looks good, please sign the CLA and fix the title
Closing in favor of #2893