Skip to content

Commit

Permalink
chore: Add null check for PolicyUtils (appsmithorg#36341)
Browse files Browse the repository at this point in the history
## Description
Sorry forgot to add the null check in my previous PR
appsmithorg@4c7ce27

/test Sanity

### 🔍 Cypress test results
<!-- This is an auto-generated comment: Cypress test results  -->
> [!TIP]
> 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
> Workflow run:
<https://github.com/appsmithorg/appsmith/actions/runs/10881430163>
> Commit: c6d853a
> <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=10881430163&attempt=1"
target="_blank">Cypress dashboard</a>.
> Tags: `@tag.Sanity`
> Spec:
> <hr>Mon, 16 Sep 2024 10:11:20 UTC
<!-- end of auto-generated comment: Cypress test results  -->


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


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

## Summary by CodeRabbit

- **Bug Fixes**
- Improved error handling in the permissions system by adding a null
check for policies, preventing potential crashes.
- **Refactor**
- Enhanced the robustness of the permission checking method to ensure
stability when handling null inputs.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
  • Loading branch information
abhvsn authored Sep 17, 2024
1 parent 5dfbe8c commit 7421748
Showing 1 changed file with 3 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ public class PolicyUtil {
public static boolean isPermissionPresentInPolicies(
String permission, Set<Policy> policies, Set<String> userPermissionGroupIds) {

if (policies == null) {
return FALSE;
}
Optional<Policy> interestingPolicyOptional = policies.stream()
.filter(policy -> policy.getPermission().equals(permission))
.findFirst();
Expand Down

0 comments on commit 7421748

Please sign in to comment.