feat: add runtime prop validation for SupportUsButton - #42
Conversation
|
Warning Review limit reached
Next review available in: 38 minutes You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
WalkthroughSupportUsButton now validates runtime props with ChangesSupportUsButton prop validation
Estimated code review effort: 3 (Moderate) | ~20 minutes Mergeability Score: 🟡 Moderate · up to The new runtime validation can mutate caller-owned nested props and throw when those objects are frozen, potentially interrupting SupportUsButton rendering; it may also emit warnings in production browsers. The PR should address these bounded issues before merging. Sequence Diagram(s)sequenceDiagram
participant SupportUsButton
participant validateProps
participant Console
SupportUsButton->>validateProps: pass received props
validateProps->>Console: warn about invalid values
validateProps-->>SupportUsButton: return normalized props
SupportUsButton-->>SupportUsButton: continue setup and rendering
Possibly related PRs
Suggested labels: Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (3 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/components/SupportUsButton.tsx`:
- Around line 84-93: Update SupportUsButton’s prop handling after validateProps
so malformed public values are normalized to safe defaults before rendering, or
guard each dependent section before dereferencing them. Ensure null ctaSection,
invalid border or organizationInformation, and malformed sponsor-link entries
only warn and never throw, while valid props retain their existing rendering
behavior.
In `@src/utils/validateProps.ts`:
- Around line 12-14: Update the warn function in validateProps.ts to check the
framework-agnostic development configuration before calling console.warn. Ensure
validation warnings remain available during development but produce no console
output in production, while preserving the existing message format.
🪄 Autofix
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: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 0b2a4432-b72d-493b-ba8e-4c6b04457fe2
📒 Files selected for processing (2)
src/components/SupportUsButton.tsxsrc/utils/validateProps.ts
|
@jikrana1, Please address codeRabbit comments and mark them as resolved after resolving them. |
|
ok |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/utils/validateProps.ts`:
- Around line 245-289: Update the sponsor normalization callback and the
CTA-link validation logic to avoid mutating caller-owned nested objects: create
normalized clones, apply trimmed or removed fields to the clones, and return
those clones from the filters. Remove direct assignments and deletions on each
input sponsor or link while preserving the existing validation and warning
behavior.
🪄 Autofix
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: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 202a9b4a-f6bc-452e-8bbc-2c7214ae91e6
📒 Files selected for processing (2)
src/components/SupportUsButton.tsxsrc/utils/validateProps.ts
|
@jikrana1 share any visuals of the working code (e.g. screen recording etc.). |
|
Hi @rahul-vyas-dev , sharing visual proof of the fix working: Test 1 — Empty required field
Test 2 — Invalid enum value
Test 3 — Null object (the original CodeRabbit crash scenario)
|
|
@jikrana1 nice work. |






Addressed Issues:
Fixes #40
Screenshots:
The screenshot demonstrates the runtime warning shown when
organizationInformation.nameis empty.Additional Notes:
validatePropsutility for runtime prop validation.console.warn()messages for invalid prop values.Checklist
We encourage contributors to use AI tools responsibly when creating Pull Requests. While AI can be a valuable aid, it is essential that your contributions meet the task requirements, build successfully, include relevant tests, and pass all linters. Submissions may be closed if they do not meet the task requirements or project standards.
Summary by CodeRabbit