Skip to content

Commit 234da90

Browse files
committed
fix: circumvent exception for child teams in dry-run mode when parent team also isn't existent yet
1 parent 6efcde3 commit 234da90

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

gh_org_mgr/_gh_org.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,18 @@ def create_missing_teams(self, dry: bool = False):
294294
for team, attributes in self.configured_teams.items():
295295
if team not in existent_team_names:
296296
if parent := attributes.get("parent"): # type: ignore
297-
parent_id = self.org.get_team_by_slug(sluggify_teamname(parent)).id
297+
try:
298+
parent_id = self.org.get_team_by_slug(sluggify_teamname(parent)).id
299+
except UnknownObjectException:
300+
if dry:
301+
logging.debug(
302+
"For team %s, the configured parent team's ('%s') ID wasn't found, "
303+
"probably because it should be created but it's a dry-run. "
304+
"We set a default ID of 424242",
305+
team,
306+
parent,
307+
)
308+
parent_id = 424242
298309

299310
logging.info("Creating team '%s' with parent ID '%s'", team, parent_id)
300311
self.stats.create_team(team)

0 commit comments

Comments
 (0)