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: RBAC errors not showing toasts #36244

Merged
merged 3 commits into from
Sep 11, 2024
Merged

fix: RBAC errors not showing toasts #36244

merged 3 commits into from
Sep 11, 2024

Conversation

hetunandu
Copy link
Member

@hetunandu hetunandu commented Sep 11, 2024

Description

Updates the error handling for Access Control scenarios to show toasts when correct permissions are not present

Fixes #36229

Automation

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

🔍 Cypress test results

Caution

🔴 🔴 🔴 Some tests have failed.
Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/10807287223
Commit: 08edaee
Cypress dashboard.
Tags: @tag.AccessControl
Spec:
The following are new failures, please fix them before merging the PR:

  1. cypress/e2e/Regression/ServerSide/GenerateCRUD/MySQL2_Spec.ts
List of identified flaky tests.
Wed, 11 Sep 2024 08:28:37 UTC

Communication

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

  • Yes
  • No

Summary by CodeRabbit

  • New Features
    • Enhanced error handling with structured Redux actions for better state management.
    • Improved clarity in error message construction based on error types.
  • Bug Fixes
    • Refined logic for displaying toast notifications based on the show parameter.
  • Documentation
    • Updated comments for better understanding of error handling logic.

Copy link
Contributor

coderabbitai bot commented Sep 11, 2024

Walkthrough

The changes in this pull request focus on enhancing error handling within the application. Modifications include updating the copyActionSaga to improve type safety and error message clarity, as well as restructuring the validateResponse and errorSaga functions to utilize Redux actions for error management. These adjustments aim to provide a more robust and structured approach to handling errors, ensuring that appropriate notifications are displayed when access issues arise.

Changes

File Change Summary
app/client/src/sagas/ActionSagas.ts Updated error handling in copyActionSaga to enhance type safety and message clarity.
app/client/src/sagas/ErrorSagas.tsx Replaced error throwing with Redux action dispatch in validateResponse; refined errorSaga logic.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant App
    participant Redux

    User->>App: Attempt to perform action
    App->>Redux: Validate response
    alt No responseMeta
        Redux->>App: Dispatch API_ERROR action
    else responseMeta exists
        App->>User: Show success message
    end
Loading

Assessment against linked issues

Objective Addressed Explanation
Toast message display for RBAC roles when lacking write access (#36229)
Error logging in the debugger when access is denied (#36229) The changes do not explicitly address logging.

Poem

In the realm of code where errors dwell,
We’ve crafted a tale to handle them well.
With Redux in hand, we manage the flow,
Toasts now will shimmer, as access we show.
Clear messages rise, like stars in the night,
A robust solution, our code shines so bright! ✨


Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between bc59bd1 and 08edaee.

Files selected for processing (2)
  • app/client/src/sagas/ActionSagas.ts (1 hunks)
  • app/client/src/sagas/ErrorSagas.tsx (2 hunks)
Additional comments not posted (3)
app/client/src/sagas/ErrorSagas.tsx (2)

115-124: Great work on improving the error handling! The changes look good to me.

By dispatching a Redux action for API errors instead of directly throwing an error, you've made the error handling more structured and integrated it better with the application's state management. This is a positive change that enhances the robustness and maintainability of the code. Keep up the good work!


230-243: The refinements to the error handling logic look great! Well done.

The updated logic for checking the show parameter improves the clarity and predictability of when alerts are displayed. By explicitly checking for show === undefined and show === true, you've made the behavior more intuitive and aligned it with the expectations.

The comments also provide helpful context for understanding the intent behind these checks. Overall, these changes enhance the error handling mechanism and make the code more maintainable. Excellent job!

app/client/src/sagas/ActionSagas.ts (1)

798-810: Excellent improvements to the error handling in the copyActionSaga! Your changes make the code safer and more robust.

By specifying the caught error as unknown, you've enhanced the type safety of the code. This ensures that the error is handled appropriately based on its type.

The refined error message construction is also a great addition. Checking if the caught error is an instance of the Error class allows for more precise error messages. If it is an Error instance, the message is extracted directly from the error object, providing accurate information. Otherwise, a default error message is generated using the createMessage function, ensuring a fallback message is always available.

These changes improve the clarity, robustness, and maintainability of the error handling code. Great job on making these enhancements!


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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 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 Critical This issue needs immediate attention. Drop everything else Needs Triaging Needs attention from maintainers to triage Platform Administration Pod Issues related to platform administration & management Production RBAC Product Issues, requests and enhancements around RBAC. Release Blocker This issue must be resolved before the release labels Sep 11, 2024
@hetunandu hetunandu added the ok-to-test Required label for CI label Sep 11, 2024
@hetunandu hetunandu enabled auto-merge (squash) September 11, 2024 07:48
@hetunandu hetunandu merged commit 89154c5 into release Sep 11, 2024
44 of 46 checks passed
@hetunandu hetunandu deleted the fix/rbac-error-toasts branch September 11, 2024 08:36
hetunandu added a commit that referenced this pull request Sep 11, 2024
## Description

Updates the error handling for Access Control scenarios to show toasts
when correct permissions are not present


Fixes #36229

## Automation

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

### 🔍 Cypress test results
<!-- This is an auto-generated comment: Cypress test results  -->
> [!CAUTION]
> 🔴 🔴 🔴 Some tests have failed.
> Workflow run:
<https://github.com/appsmithorg/appsmith/actions/runs/10807287223>
> Commit: 08edaee
> <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=10807287223&attempt=2&selectiontype=test&testsstatus=failed&specsstatus=fail"
target="_blank">Cypress dashboard</a>.
> Tags: @tag.AccessControl
> Spec: 
> The following are new failures, please fix them before merging the PR:
<ol>
> <li>cypress/e2e/Regression/ServerSide/GenerateCRUD/MySQL2_Spec.ts</ol>
> <a
href="https://internal.appsmith.com/app/cypress-dashboard/identified-flaky-tests-65890b3c81d7400d08fa9ee3?branch=master"
target="_blank">List of identified flaky tests</a>.
> <hr>Wed, 11 Sep 2024 08:28:37 UTC
<!-- end of auto-generated comment: Cypress test results  -->


## Communication
Should the DevRel and Marketing teams inform users about this change?
- [ ] Yes
- [ ] No


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **New Features**
- Enhanced error handling with structured Redux actions for better state
management.
	- Improved clarity in error message construction based on error types.
- **Bug Fixes**
- Refined logic for displaying toast notifications based on the `show`
parameter.
- **Documentation**
	- Updated comments for better understanding of error handling logic.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Shivam-z pushed a commit to Shivam-z/appsmith that referenced this pull request Sep 26, 2024
## Description

Updates the error handling for Access Control scenarios to show toasts
when correct permissions are not present


Fixes appsmithorg#36229

## Automation

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

### 🔍 Cypress test results
<!-- This is an auto-generated comment: Cypress test results  -->
> [!CAUTION]
> 🔴 🔴 🔴 Some tests have failed.
> Workflow run:
<https://github.com/appsmithorg/appsmith/actions/runs/10807287223>
> Commit: 08edaee
> <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=10807287223&attempt=2&selectiontype=test&testsstatus=failed&specsstatus=fail"
target="_blank">Cypress dashboard</a>.
> Tags: @tag.AccessControl
> Spec: 
> The following are new failures, please fix them before merging the PR:
<ol>
> <li>cypress/e2e/Regression/ServerSide/GenerateCRUD/MySQL2_Spec.ts</ol>
> <a
href="https://internal.appsmith.com/app/cypress-dashboard/identified-flaky-tests-65890b3c81d7400d08fa9ee3?branch=master"
target="_blank">List of identified flaky tests</a>.
> <hr>Wed, 11 Sep 2024 08:28:37 UTC
<!-- end of auto-generated comment: Cypress test results  -->


## Communication
Should the DevRel and Marketing teams inform users about this change?
- [ ] Yes
- [ ] No


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **New Features**
- Enhanced error handling with structured Redux actions for better state
management.
	- Improved clarity in error message construction based on error types.
- **Bug Fixes**
- Refined logic for displaying toast notifications based on the `show`
parameter.
- **Documentation**
	- Updated comments for better understanding of error handling logic.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working Critical This issue needs immediate attention. Drop everything else Needs Triaging Needs attention from maintainers to triage ok-to-test Required label for CI Platform Administration Pod Issues related to platform administration & management Production RBAC Product Issues, requests and enhancements around RBAC. Release Blocker This issue must be resolved before the release
Projects
None yet
2 participants