Skip to content

Fixes GH-17399 #17747

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

Merged
merged 10 commits into from
Jul 22, 2025
Merged

Fixes GH-17399 #17747

merged 10 commits into from
Jul 22, 2025

Conversation

dannyroosevelt
Copy link
Collaborator

@dannyroosevelt dannyroosevelt commented Jul 22, 2025

WHY

Summary by CodeRabbit

  • New Features

    • Added development-only debug information export and automatic logging for easier troubleshooting during development.
    • Introduced new utility functions to improve option handling and normalization in selection components.
  • Bug Fixes

    • Improved handling and sanitization of option objects in selection components to ensure consistent display and prevent errors with nested or invalid option formats.
    • Enhanced robustness by providing safe fallbacks and preventing invalid options from causing issues.
  • Chores

    • Added type guard utilities to support safer and more predictable option processing.

Copy link

vercel bot commented Jul 22, 2025

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

3 Skipped Deployments
Name Status Preview Comments Updated (UTC)
docs-v2 ⬜️ Ignored (Inspect) Visit Preview Jul 22, 2025 9:45pm
pipedream-docs ⬜️ Ignored (Inspect) Jul 22, 2025 9:45pm
pipedream-docs-redirect-do-not-edit ⬜️ Ignored (Inspect) Jul 22, 2025 9:45pm

Copy link
Contributor

coderabbitai bot commented Jul 22, 2025

Warning

Rate limit exceeded

@dannyroosevelt has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 7 minutes and 18 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command 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

Reviewing files that changed from the base of the PR and between 7c6155b and b76c99a.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (4)
  • packages/connect-react/src/components/ControlSelect.tsx (9 hunks)
  • packages/connect-react/src/components/RemoteOptionsContainer.tsx (2 hunks)
  • packages/connect-react/src/index.ts (1 hunks)
  • packages/connect-react/src/utils/type-guards.ts (1 hunks)

Walkthrough

The changes introduce robust normalization and type-guard utilities for select option handling in the React components. The ControlSelect component now ensures consistent primitive labels and values, unwraps nested objects, and prevents invalid option formats. Additional debug metadata and logging are added to the package entry point, and new utility functions for type checking and normalization are implemented.

Changes

File(s) Change Summary
packages/connect-react/src/components/ControlSelect.tsx Refactored to normalize/sanitize select options and values, unwrap wrappers, add type guards, and prevent invalid data.
packages/connect-react/src/components/RemoteOptionsContainer.tsx Updated option value extraction logic to use explicit type guards and filter out invalid formats with warnings.
packages/connect-react/src/index.ts Added DEBUG_INFO export with version/build metadata and automatic dev-time logging.
packages/connect-react/src/utils/type-guards.ts Introduced OptionWithValue interface, type guard functions, and normalization utilities for option handling.

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant ControlSelect
  participant TypeGuards
  participant SelectComponent

  User->>ControlSelect: Provide options/values
  ControlSelect->>TypeGuards: Normalize and sanitize options
  TypeGuards-->>ControlSelect: Return normalized options/values
  ControlSelect->>SelectComponent: Pass sanitized options/values
  SelectComponent-->>ControlSelect: User selects/creates option
  ControlSelect->>TypeGuards: Validate/unwrap selected value
  TypeGuards-->>ControlSelect: Return clean option/value
  ControlSelect-->>User: Emit change event with sanitized value
Loading

Estimated code review effort

3 (~45 minutes)

Poem

In fields of code where options grow,
The rabbits hop, unwrap, and know —
No wrappers left, no nested fright,
Just labels, values, pure and right.
Debug info shines in console light,
Type guards keep the codepath bright.
🐇✨

✨ 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
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: 4

🧹 Nitpick comments (2)
packages/connect-react/src/components/ControlSelect.tsx (2)

244-269: Consider the performance impact of multiple sanitizations

The options are being sanitized multiple times - in the useEffect, in handleCreate, and again before rendering. This could impact performance with large option lists.

Consider sanitizing options only once when they change and storing the sanitized version in state:

  const [
    selectOptions,
    setSelectOptions,
  ] = useState(options);
+ const [
+   sanitizedSelectOptions,
+   setSanitizedSelectOptions,
+ ] = useState([]);

  useEffect(() => {
    const sanitizedOptions = options.map(sanitizeOption);
    setSelectOptions(sanitizedOptions);
+   setSanitizedSelectOptions(sanitizedOptions);
  }, [options]);

Then use sanitizedSelectOptions directly in the render without the need for cleanedOptions.


173-210: Improve type safety in handleCreate function

The createOption function is defined inside handleCreate but uses unknown type. Since we know the input is a string, we can improve type safety.

  const handleCreate = (inputValue: string) => {
-    const createOption = (input: unknown): OptionWithValue => {
-      if (isOptionWithValue(input)) return input
-      const strValue = String(input);
+    const createOption = (input: string | OptionWithValue): OptionWithValue => {
+      if (isOptionWithValue(input)) return input;
       return {
-        label: strValue,
-        value: strValue,
+        label: input,
+        value: input,
       }
     }
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between fb9dc84 and 25acc0c.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (4)
  • packages/connect-react/src/components/ControlSelect.tsx (9 hunks)
  • packages/connect-react/src/components/RemoteOptionsContainer.tsx (2 hunks)
  • packages/connect-react/src/index.ts (1 hunks)
  • packages/connect-react/src/utils/type-guards.ts (1 hunks)
🧠 Learnings (5)
📓 Common learnings
Learnt from: jverce
PR: PipedreamHQ/pipedream#15479
File: packages/connect-react/src/components/ComponentForm.tsx:23-24
Timestamp: 2025-02-05T21:58:03.118Z
Learning: In the connect-react package, the `enableDebugging` property should be of type `boolean` as it's used for toggling debugging features and conditional rendering.
packages/connect-react/src/components/RemoteOptionsContainer.tsx (1)

Learnt from: jverce
PR: #15479
File: packages/connect-react/src/components/ComponentForm.tsx:23-24
Timestamp: 2025-02-05T21:58:03.118Z
Learning: In the connect-react package, the enableDebugging property should be of type boolean as it's used for toggling debugging features and conditional rendering.

packages/connect-react/src/index.ts (2)

Learnt from: jverce
PR: #15479
File: packages/connect-react/src/components/ComponentForm.tsx:23-24
Timestamp: 2025-02-05T21:58:03.118Z
Learning: In the connect-react package, the enableDebugging property should be of type boolean as it's used for toggling debugging features and conditional rendering.

Learnt from: jcortes
PR: #14935
File: components/sailpoint/package.json:15-18
Timestamp: 2024-12-12T19:23:09.039Z
Learning: When developing Pipedream components, do not add built-in Node.js modules like fs to package.json dependencies, as they are native modules provided by the Node.js runtime.

packages/connect-react/src/components/ControlSelect.tsx (2)

Learnt from: dylburger
PR: #12685
File: packages/sdk/examples/next-app/app/CodePanel.tsx:42-42
Timestamp: 2024-10-08T15:33:38.240Z
Learning: In React components, use DOMPurify.sanitize to sanitize HTML content instead of using dangerouslySetInnerHTML to prevent XSS attacks.

Learnt from: dylburger
PR: #12685
File: packages/sdk/examples/next-app/app/CodePanel.tsx:42-42
Timestamp: 2024-08-14T17:26:51.614Z
Learning: In React components, use DOMPurify.sanitize to sanitize HTML content instead of using dangerouslySetInnerHTML to prevent XSS attacks.

packages/connect-react/src/utils/type-guards.ts (1)

Learnt from: jverce
PR: #14106
File: packages/sdk/src/server/tests/server.test.ts:174-192
Timestamp: 2024-10-31T23:57:17.282Z
Learning: In packages/sdk/src/server/__tests__/server.test.ts, when @ts-ignore annotations are used in mock implementations, they are acceptable, and replacing them with type casting or mock types is unnecessary.

🧬 Code Graph Analysis (1)
packages/connect-react/src/components/RemoteOptionsContainer.tsx (1)
packages/connect-react/src/utils/type-guards.ts (1)
  • isString (7-9)
🧰 Additional context used
🧠 Learnings (5)
📓 Common learnings
Learnt from: jverce
PR: PipedreamHQ/pipedream#15479
File: packages/connect-react/src/components/ComponentForm.tsx:23-24
Timestamp: 2025-02-05T21:58:03.118Z
Learning: In the connect-react package, the `enableDebugging` property should be of type `boolean` as it's used for toggling debugging features and conditional rendering.
packages/connect-react/src/components/RemoteOptionsContainer.tsx (1)

Learnt from: jverce
PR: #15479
File: packages/connect-react/src/components/ComponentForm.tsx:23-24
Timestamp: 2025-02-05T21:58:03.118Z
Learning: In the connect-react package, the enableDebugging property should be of type boolean as it's used for toggling debugging features and conditional rendering.

packages/connect-react/src/index.ts (2)

Learnt from: jverce
PR: #15479
File: packages/connect-react/src/components/ComponentForm.tsx:23-24
Timestamp: 2025-02-05T21:58:03.118Z
Learning: In the connect-react package, the enableDebugging property should be of type boolean as it's used for toggling debugging features and conditional rendering.

Learnt from: jcortes
PR: #14935
File: components/sailpoint/package.json:15-18
Timestamp: 2024-12-12T19:23:09.039Z
Learning: When developing Pipedream components, do not add built-in Node.js modules like fs to package.json dependencies, as they are native modules provided by the Node.js runtime.

packages/connect-react/src/components/ControlSelect.tsx (2)

Learnt from: dylburger
PR: #12685
File: packages/sdk/examples/next-app/app/CodePanel.tsx:42-42
Timestamp: 2024-10-08T15:33:38.240Z
Learning: In React components, use DOMPurify.sanitize to sanitize HTML content instead of using dangerouslySetInnerHTML to prevent XSS attacks.

Learnt from: dylburger
PR: #12685
File: packages/sdk/examples/next-app/app/CodePanel.tsx:42-42
Timestamp: 2024-08-14T17:26:51.614Z
Learning: In React components, use DOMPurify.sanitize to sanitize HTML content instead of using dangerouslySetInnerHTML to prevent XSS attacks.

packages/connect-react/src/utils/type-guards.ts (1)

Learnt from: jverce
PR: #14106
File: packages/sdk/src/server/tests/server.test.ts:174-192
Timestamp: 2024-10-31T23:57:17.282Z
Learning: In packages/sdk/src/server/__tests__/server.test.ts, when @ts-ignore annotations are used in mock implementations, they are acceptable, and replacing them with type casting or mock types is unnecessary.

🧬 Code Graph Analysis (1)
packages/connect-react/src/components/RemoteOptionsContainer.tsx (1)
packages/connect-react/src/utils/type-guards.ts (1)
  • isString (7-9)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Lint Code Base
🔇 Additional comments (2)
packages/connect-react/src/components/RemoteOptionsContainer.tsx (1)

142-151: Good improvement in type safety with proper validation

The refactored code properly validates option formats and logs warnings for invalid data, which will help with debugging.

However, note that the type check on line 145 for o.value != null might not catch all edge cases. Since value is typed as string | number, you might want to explicitly check for these types:

-        } else if (o && typeof o === "object" && "value" in o && o.value != null) {
+        } else if (isOptionWithValue(o)) {
           value = o.value;

This would reuse the type guard you've already imported and ensure consistency.

packages/connect-react/src/components/ControlSelect.tsx (1)

280-286: Good addition of getOptionLabel and getOptionValue props

The explicit getOptionLabel and getOptionValue props ensure react-select can handle both string and object options correctly.

@dannyroosevelt dannyroosevelt merged commit d9b91ad into master Jul 22, 2025
8 checks passed
@dannyroosevelt dannyroosevelt deleted the danny/connect-react/gh-17399 branch July 22, 2025 22:09
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.

[BUG] Error thrown when configuring folderId prop in microsoft_excel-new-row-added trigger
2 participants