Skip to content

feat: add runtime prop validation for SupportUsButton - #42

Merged
rahul-vyas-dev merged 3 commits into
AOSSIE-Org:mainfrom
jikrana1:feat/runtime-prop-validation
Aug 13, 2026
Merged

feat: add runtime prop validation for SupportUsButton#42
rahul-vyas-dev merged 3 commits into
AOSSIE-Org:mainfrom
jikrana1:feat/runtime-prop-validation

Conversation

@jikrana1

@jikrana1 jikrana1 commented Aug 12, 2026

Copy link
Copy Markdown

Addressed Issues:

Fixes #40

Screenshots:

Runtime prop validation warning

The screenshot demonstrates the runtime warning shown when organizationInformation.name is empty.

Additional Notes:

  • Added a dedicated validateProps utility for runtime prop validation.
  • Added clear console.warn() messages for invalid prop values.
  • Validation does not throw errors or interrupt rendering.
  • Existing TypeScript type safety remains unchanged.

Checklist

  • My code follows the project's code style and conventions
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings or errors
  • I have joined the Discord server and I will share a link to this PR with the project maintainers there
  • I have read the Contributing Guidelines

⚠️ AI Notice - Important!

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

  • Bug Fixes
    • Added validation and normalization for Support Us button settings, including themes, content, links, logos, styling, sponsors, and borders.
    • Invalid configuration values now fall back to safe defaults or are omitted when appropriate.
    • Clear console warnings are provided for invalid values outside production environments.

@github-actions github-actions Bot added enhancement New feature or request frontend Changes to frontend code javascript JavaScript/TypeScript code changes size/L Large PR (201-500 lines changed) first-time-contributor First PR of an external contributor pending-coderabbit-review labels Aug 12, 2026
@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@jikrana1, you've reached your PR review limit, so we couldn't start this review.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 58293cf2-3e7f-4e49-8280-672c898473a6

📥 Commits

Reviewing files that changed from the base of the PR and between c75b4d3 and 9a16571.

📒 Files selected for processing (1)
  • src/utils/validateProps.ts

Walkthrough

SupportUsButton now validates runtime props with validateProps. The utility normalizes supported values, filters invalid nested data, applies safe defaults, and emits development warnings without interrupting rendering.

Changes

SupportUsButton prop validation

Layer / File(s) Summary
Prop validation rules
src/utils/validateProps.ts
Adds validation for themes, organization and project data, sponsors, CTA links, logos, class names, and border values. Invalid values receive safe fallbacks or removal, with warnings outside production.
Component validation integration
src/components/SupportUsButton.tsx
Imports validateProps, validates the props object, and uses the normalized result for defaults and rendering.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Mergeability Score: 🟡 Moderate · up to c75b4

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
Loading

Possibly related PRs

Suggested labels: Typescript Lang

Suggested reviewers: rahul-vyas-dev, reach2saksham

Poem

A rabbit checks each prop in line,
And normalizes each design.
Warnings hop when values fail,
Safe defaults keep the render trail.
The button bounds through every tale.

🚥 Pre-merge checks | ✅ 3 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The PR adds runtime validation and warnings, but normalization and fallback behavior may still change production behavior required by issue #40. Gate validation and fallback behavior outside production, or confirm that production sanitization is explicitly intended by issue #40.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the main change: runtime prop validation for SupportUsButton.
Out of Scope Changes check ✅ Passed The changes are limited to SupportUsButton integration and its validation utility, which directly support issue #40.
✨ 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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

📥 Commits

Reviewing files that changed from the base of the PR and between bafae18 and 9345511.

📒 Files selected for processing (2)
  • src/components/SupportUsButton.tsx
  • src/utils/validateProps.ts

Comment thread src/components/SupportUsButton.tsx Outdated
Comment thread src/utils/validateProps.ts
@rahul-vyas-dev

Copy link
Copy Markdown
Contributor

@jikrana1, Please address codeRabbit comments and mark them as resolved after resolving them.

@jikrana1

Copy link
Copy Markdown
Author

ok

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

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

📥 Commits

Reviewing files that changed from the base of the PR and between 9345511 and c75b4d3.

📒 Files selected for processing (2)
  • src/components/SupportUsButton.tsx
  • src/utils/validateProps.ts

Comment thread src/utils/validateProps.ts Outdated
@rahul-vyas-dev

Copy link
Copy Markdown
Contributor

@jikrana1 share any visuals of the working code (e.g. screen recording etc.).

@jikrana1

Copy link
Copy Markdown
Author

Hi @rahul-vyas-dev , sharing visual proof of the fix working:

Test 1 — Empty required field


image image

Test 2 — Invalid enum value

image image

Test 3 — Null object (the original CodeRabbit crash scenario)

image image

@rahul-vyas-dev

Copy link
Copy Markdown
Contributor

@jikrana1 nice work.

@rahul-vyas-dev
rahul-vyas-dev merged commit 5b32eb9 into AOSSIE-Org:main Aug 13, 2026
6 of 7 checks passed
@jikrana1
jikrana1 deleted the feat/runtime-prop-validation branch August 13, 2026 06:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request first-time-contributor First PR of an external contributor frontend Changes to frontend code javascript JavaScript/TypeScript code changes pending-coderabbit-review size/L Large PR (201-500 lines changed)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] : Add runtime prop validation utility for SupportUsButton

2 participants