Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
Expand All @@ -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(
Expand All @@ -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);
Comment thread
RajdeepKushwaha5 marked this conversation as resolved.
}
}
return false;
Expand All @@ -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());
Expand Down Expand Up @@ -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(
Expand All @@ -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
Copy link

Copilot AI Apr 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The warning log in this catch block calls currentTeamRef.getName(). If the original exception was due to a null/invalid team reference (or missing name), this log statement can throw and propagate, breaking the intended fail-closed behavior (method should keep iterating and eventually return false). Please make the logging null-safe (e.g., conditional name/id formatting) so the catch block cannot throw.

Copilot uses AI. Check for mistakes.
ex);
}
}
return false;
Expand Down Expand Up @@ -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);
}
}
}
Expand Down
Loading