Skip to content
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: Enhance error handling in ComputeTablePropertyControlV2 binding methods #38205

Draft
wants to merge 3 commits into
base: release
Choose a base branch
from

Conversation

rahulbarwal
Copy link
Contributor

@rahulbarwal rahulbarwal commented Dec 17, 2024

Description

Updated the binding methods in ComputeTablePropertyControlV2 to improve error handling. The binding prefix now includes a try-catch block to prevent runtime errors when processing table data, ensuring that null values are returned gracefully in case of exceptions.

Fixes #38157
or
Fixes Issue URL

Warning

If no issue exists, please create an issue first, and check with the maintainers if the issue is valid.

Automation

/ok-to-test tags="@tag.Table"

🔍 Cypress test results

Warning

Tests have not run on the HEAD 7bf1714 yet


Tue, 17 Dec 2024 12:55:04 UTC

Communication

Should the DevRel and Marketing teams inform users about this change?

  • Yes
  • No

Summary by CodeRabbit

  • New Features

    • Enhanced error handling in the binding logic for improved robustness.
    • Improved type safety in data transformation processes.
  • Bug Fixes

    • Resolved potential runtime errors during binding expression evaluation.
  • Documentation

    • Updated method signatures and variable types for clarity and consistency.

…methods

Updated the binding methods in `ComputeTablePropertyControlV2` to improve error handling. The binding prefix now includes a try-catch block to prevent runtime errors when processing table data, ensuring that null values are returned gracefully in case of exceptions.
@rahulbarwal rahulbarwal requested a review from a team as a code owner December 17, 2024 08:09
Copy link
Contributor

coderabbitai bot commented Dec 17, 2024

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

The pull request addresses a bug related to JSON values being displayed in table cells when certain rows lack corresponding values. The changes involve modifying error handling in the TableComputeValue.tsx and updating type definitions in transformDataPureFn.tsx. The modifications aim to improve type safety and prevent unexpected rendering of JSON data when computed values are missing.

Changes

File Change Summary
app/client/src/components/propertyControls/TableComputeValue.tsx Enhanced error handling in getBindingPrefix and bindingSuffix methods
app/client/src/widgets/TableWidgetV2/widget/reactTableUtils/transformDataPureFn.tsx Updated newRow type from any to unknown for improved type safety

Assessment against linked issues

Objective Addressed Explanation
Prevent JSON display for missing values [#38157]
Handle undefined values in computed columns Requires further testing to confirm complete resolution

Possibly related PRs

Suggested labels

Bug, High, Production, ok-to-test, Widgets Product, Help enterprise

Suggested reviewers

  • ApekshaBhosale

Poem

Code flows like a river wild,
Catching errors, data reconciled,
Type safety, our guardian bright,
Transforming chaos into light,
Debugging magic takes its flight! 🚀✨


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?

❤️ 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.
    • 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 @coderabbitai in 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 @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 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 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. (Beta)
  • @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.

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.

@github-actions github-actions bot added Bug Something isn't working Medium Issues that frustrate users due to poor UX Needs Triaging Needs attention from maintainers to triage Production Table Widget V2 Issues related to Table Widget V2 Widgets & Accelerators Pod Issues related to widgets & Accelerators Widgets Product This label groups issues related to widgets labels Dec 17, 2024
@rahulbarwal rahulbarwal marked this pull request as draft December 17, 2024 08:09
@rahulbarwal
Copy link
Contributor Author

/build-deploy-preview skip-tests=true

Copy link

Deploying Your Preview: https://github.com/appsmithorg/appsmith/actions/runs/12368869711.
Workflow: On demand build Docker image and deploy preview.
skip-tests: true.
env: ``.
PR: 38205.
recreate: .

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

🧹 Nitpick comments (1)
app/client/src/components/propertyControls/TableComputeValue.tsx (1)

106-106: Consider logging errors before returning null

While returning null is a good fallback, silently swallowing errors might make debugging harder.

Consider adding error logging:

-  static bindingSuffix = `); } catch (e) { return null; }})}}`;
+  static bindingSuffix = `); } catch (e) { console.error('Table computation error:', e); return null; }})}}`;
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d905a4c and 2a202cb.

📒 Files selected for processing (2)
  • app/client/src/components/propertyControls/TableComputeValue.tsx (1 hunks)
  • app/client/src/widgets/TableWidgetV2/widget/reactTableUtils/transformDataPureFn.tsx (1 hunks)
🔇 Additional comments (3)
app/client/src/widgets/TableWidgetV2/widget/reactTableUtils/transformDataPureFn.tsx (1)

19-19: Good type safety improvement!

Changing from any to unknown enforces better type checking and reduces potential runtime errors.

app/client/src/components/propertyControls/TableComputeValue.tsx (2)

103-103: Good addition of try block for error isolation

The try block ensures that errors in one row's computation don't affect other rows.


103-106: Verify impact on existing error handling

The new error handling affects all computed values. Let's verify there are no duplicate error handlers or logging.

✅ Verification successful

Let me analyze the error handling patterns in the codebase to verify if there are any duplicate handlers or logging conflicts.


Error handling implementation is appropriate

The error handling in TableComputeValue.tsx is correctly implemented and doesn't conflict with other error handlers. The catch block returns null for computation errors, while other handlers in the table widget ecosystem handle specific scenarios (date parsing, local data reading, etc.) with appropriate logging.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for existing error handling in table computation code
rg -A 2 "catch \(e\)" --type ts

Length of output: 65866


Script:

#!/bin/bash
# Search for error handling in table computation and related files
rg -A 2 "catch \(e\)" --type ts app/client/src/components/propertyControls/TableComputeValue.tsx app/client/src/widgets/TableWidgetV2/widget/utilities.ts app/client/src/widgets/TableWidgetV2/widget/propertyUtils.ts app/client/src/widgets/TableWidgetV2/widget/reactTableUtils/transformDataPureFn.tsx

Length of output: 2546

Copy link

Deploy-Preview-URL: https://ce-38205.dp.appsmith.com

@rahulbarwal
Copy link
Contributor Author

/build-deploy-preview skip-tests=true

Copy link

Deploying Your Preview: https://github.com/appsmithorg/appsmith/actions/runs/12373445425.
Workflow: On demand build Docker image and deploy preview.
skip-tests: true.
env: ``.
PR: 38205.
recreate: .

Copy link

Deploy-Preview-URL: https://ce-38205.dp.appsmith.com

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working Medium Issues that frustrate users due to poor UX Needs Triaging Needs attention from maintainers to triage Production Table Widget V2 Issues related to Table Widget V2 Widgets & Accelerators Pod Issues related to widgets & Accelerators Widgets Product This label groups issues related to widgets
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: JSON values are shown in the table cell, when one of the rows does not contain corresponding value.
1 participant