-
-
Notifications
You must be signed in to change notification settings - Fork 868
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
Fix: User-friendly error message for empty comments #3146
Fix: User-friendly error message for empty comments #3146
Conversation
WalkthroughThe pull request focuses on improving the error handling mechanism in the Changes
Assessment against linked issues
Poem
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? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
Documentation and Community
|
Our Pull Request Approval ProcessThanks for contributing! Testing Your CodeRemember, your PRs won't be reviewed until these criteria are met:
Our policies make our code better. ReviewersDo not assign reviewers. Our Queue Monitors will review your PR and assign them.
Reviewing Your CodeYour reviewer(s) will have the following roles:
CONTRIBUTING.mdRead our CONTRIBUTING.md file. Most importantly:
Other
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Congratulations on making your first PR! 🎊 If you haven't already, check out our Contributing Guidelines and PR Reporting Guidelines to ensure that you are following our guidelines for contributing and creating PR.
There was a problem hiding this 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)
src/components/UserPortal/PostCard/PostCard.tsx (1)
228-236
: Consider refining the error handling approach for more robust user feedback.While this new logic successfully strips out the technical prefix for comment validation errors, there are a few potential improvements:
- Localize the user-friendly message: If you plan to display the message in different languages, wrap the final string in a translation function (
t()
) instead of callingtoast.error
with a raw string.- Check for partial matches: Confirm that only comment-validation-specific errors get scrubbed. If other error messages contain “text:” or “Comment validation failed:”, they might be inadvertently stripped as well.
- Log the original error message if necessary: If you want to preserve the technical message for debugging, consider logging it or sending it to an external monitoring service rather than discarding it.
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
package-lock.json
is excluded by!**/package-lock.json
📒 Files selected for processing (1)
src/components/UserPortal/PostCard/PostCard.tsx
(1 hunks)
The base branch was changed.
Please submit your PRs against our Also if applicable, make sure your branch name is different from Closing. |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #3146 +/- ##
============================================
+ Coverage 29.13% 88.89% +59.76%
============================================
Files 300 321 +21
Lines 7568 8412 +844
Branches 1652 1895 +243
============================================
+ Hits 2205 7478 +5273
+ Misses 5177 692 -4485
- Partials 186 242 +56 ☔ View full report in Codecov by Sentry. |
What kind of change does this PR introduce?
Bugfix
Issue Number:
Fixes #3142
Did you add tests for your changes?
Yes
Snapshots/Videos:
Before fix :
![Screenshot 2025-01-05 015249](https://private-user-images.githubusercontent.com/141390434/400174267-0386f655-1297-4940-9f0f-26ee48ffa20b.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkyODM0NzMsIm5iZiI6MTczOTI4MzE3MywicGF0aCI6Ii8xNDEzOTA0MzQvNDAwMTc0MjY3LTAzODZmNjU1LTEyOTctNDk0MC05ZjBmLTI2ZWU0OGZmYTIwYi5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwMjExJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDIxMVQxNDEyNTNaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT0xNmYxZDNmZDI1M2VkYmQ1YTI1ODFiM2U5Nzc5NTY0MWFmMTBmMGEwZGU2MzFiOGI0NjRmNDE3NGQ4YzY0YTQ4JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.AwF7Ot51cEvAVCatx_SzKMacxcNuBM1GWSb1zgRw5Qo)
After fix :
![Screenshot 2025-01-05 021900](https://private-user-images.githubusercontent.com/141390434/400174279-7f2984f5-0b82-4c12-9638-35c38956a192.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkyODM0NzMsIm5iZiI6MTczOTI4MzE3MywicGF0aCI6Ii8xNDEzOTA0MzQvNDAwMTc0Mjc5LTdmMjk4NGY1LTBiODItNGMxMi05NjM4LTM1YzM4OTU2YTE5Mi5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwMjExJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDIxMVQxNDEyNTNaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1lMDRjMjE3NTJjZGE0ZDljNjhjZGNjMGM4NWZhYWY2ODNhMzEzNjg0YWI4Y2JmYTUzMTEwZTYzNWRmMTczMzk1JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.xnOJa8eK5PJbu5szc5Q1Afjma1mn01hWkSVZCUQDY3g)
If relevant, did you update the documentation?
No
Summary
This PR resolves the issue where submitting an empty comment displayed a technical error message (Comment validation failed: text: Path 'text' is required.). The error message is now replaced with a user-friendly one (Please enter a comment before submitting.), enhancing the user experience. The technical message remains in the logs for developers.
Does this PR introduce a breaking change?
No
Other information
Ensure to test the functionality with the updated backend (talawa-api) to verify the integration works as intended.
Have you read the contributing guide?
Yes
Summary by CodeRabbit