The retrieveTeamDynamixGroupByName method searches TeamDynamix using NameLike, which does a fuzzy/like match. The API may return groups that contain the name but don't match exactly. The code then filters for an exact match:
{{while (iterator.hasNext()) {JsonNode groupNode = iterator.next();TeamDynamixGroup teamDynamixGroup = TeamDynamixGroup.fromJson(groupNode);if (StringUtils.equals(teamDynamixGroup.getName(), groupName)) { groups.add(teamDynamixGroup);}}if (groups.size() > 1)
return groups.get(0); // <-- crashes if groups is empty}}
If the API returns results (so we don't hit the early return null on line 749-751) but none match exactly, groups is empty and groups.get(0) throws IndexOutOfBoundsException.
For example, searching for group name "Test" — the API might return "Test Group" and "My Test" via the like match, but neither equals "Test" exactly, so the filtered list is empty.
The fix would be:
return groups.size() == 1 ? groups.get(0) : null;