-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Fixes #27093 : Add warning logging to silent catch blocks in SubjectContext #27094
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
base: main
Are you sure you want to change the base?
Changes from all commits
1790851
296b277
908e603
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -169,7 +169,12 @@ public boolean isTeamAsset(String parentTeam, List<EntityReference> owners) { | |
| Entity.getEntity(Entity.TEAM, owner.getId(), TEAM_FIELDS, Include.NON_DELETED); | ||
| return isInTeam(parentTeam, team.getEntityReference()); | ||
| } catch (Exception ex) { | ||
| // Ignore and return false | ||
| LOG.warn( | ||
| "Failed to check team asset ownership for team [{}] with owner [{}]: {}", | ||
| parentTeam, | ||
| owner.getId(), | ||
| ex.getMessage(), | ||
| ex); | ||
| } | ||
| } | ||
| } | ||
|
|
@@ -182,8 +187,8 @@ public static boolean isInTeam(String parentTeam, EntityReference team) { | |
| Set<UUID> visitedTeams = new HashSet<>(); | ||
| stack.push(team); // Start with team and see if the parent matches | ||
| while (!stack.isEmpty()) { | ||
| EntityReference currentTeamRef = stack.pop(); | ||
| try { | ||
| EntityReference currentTeamRef = stack.pop(); | ||
| // Skip if we've already visited this team to prevent circular dependencies | ||
| if (visitedTeams.contains(currentTeamRef.getId())) { | ||
| LOG.warn( | ||
|
|
@@ -199,7 +204,12 @@ public static boolean isInTeam(String parentTeam, EntityReference team) { | |
| listOrEmpty(parent.getParents()) | ||
| .forEach(stack::push); // Continue to go up the chain of parents | ||
| } catch (Exception ex) { | ||
| // Ignore and return false | ||
| LOG.warn( | ||
| "Failed to traverse team hierarchy for parent [{}] at team [{}]: {}", | ||
| parentTeam, | ||
| currentTeamRef != null ? currentTeamRef.getName() : null, | ||
| ex.getMessage(), | ||
| ex); | ||
| } | ||
| } | ||
| return false; | ||
|
|
@@ -226,7 +236,8 @@ private static List<EntityReference> getRolesForTeams( | |
| roles.addAll(team.getDefaultRoles()); | ||
| roles.addAll(getRolesForTeams(team.getParents(), visitedTeams)); | ||
| } catch (Exception ex) { | ||
| // Ignore and continue | ||
| LOG.warn( | ||
| "Failed to resolve roles for team [{}]: {}", teamRef.getName(), ex.getMessage(), ex); | ||
| } | ||
| } | ||
| return roles.stream().distinct().collect(Collectors.toList()); | ||
|
|
@@ -280,8 +291,8 @@ public static boolean hasRole(User user, String role) { | |
| } | ||
| listOrEmpty(user.getTeams()).forEach(stack::push); // Continue to go up the chain of parents | ||
| while (!stack.isEmpty()) { | ||
| EntityReference currentTeamRef = stack.pop(); | ||
| try { | ||
| EntityReference currentTeamRef = stack.pop(); | ||
| // Skip if we've already visited this team to prevent circular dependencies | ||
| if (visitedTeams.contains(currentTeamRef.getId())) { | ||
| LOG.warn( | ||
|
|
@@ -298,7 +309,12 @@ public static boolean hasRole(User user, String role) { | |
| listOrEmpty(parent.getParents()) | ||
| .forEach(stack::push); // Continue to go up the chain of parents | ||
| } catch (Exception ex) { | ||
| // Ignore the exception and return false | ||
| LOG.warn( | ||
| "Failed to check role [{}] for team [{}]: {}", | ||
| role, | ||
| currentTeamRef != null ? currentTeamRef.getName() : null, | ||
| ex.getMessage(), | ||
|
Comment on lines
+312
to
+316
|
||
| ex); | ||
| } | ||
| } | ||
| return false; | ||
|
|
@@ -471,7 +487,11 @@ static class UserPolicyIterator implements Iterator<PolicyContext> { | |
| Entity.TEAM, resourceOwner.getId(), TEAM_FIELDS, Include.NON_DELETED); | ||
| iterators.add(new TeamPolicyIterator(team.getId(), teamsVisited, true)); | ||
| } catch (Exception ex) { | ||
| // Ignore | ||
| LOG.warn( | ||
| "Failed to load policies for resource owner team [{}]: {}", | ||
| resourceOwner.getId(), | ||
| ex.getMessage(), | ||
| ex); | ||
| } | ||
| } | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.