Skip to content

Commit a99cfc5

Browse files
committed
fix: guard role mutations with empty persisted scores; harden PR label workflow; docs updates
1 parent 33b62f6 commit a99cfc5

1 file changed

Lines changed: 21 additions & 14 deletions

File tree

src/ghdcbot/engine/orchestrator.py

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -223,20 +223,27 @@ def run_once(self) -> None:
223223
apply_github_plans(self.github_writer, issue_plans, review_plans, policy, self.config.github.org)
224224
merge_role_rules = getattr(self.config, "merge_role_rules", None)
225225
repo_contributor_roles = getattr(self.config, "repo_contributor_roles", None)
226-
if getattr(self.config.runtime, "enable_discord_role_updates", True):
227-
apply_discord_roles(
228-
self.discord_writer,
229-
member_roles,
230-
scores,
231-
identity_mappings,
232-
self.config.role_mappings,
233-
policy,
234-
storage=self.storage,
235-
period_start=period_start,
236-
period_end=period_end,
237-
merge_role_rules=merge_role_rules,
238-
repo_contributor_roles=repo_contributor_roles,
239-
)
226+
if enable_discord_role_updates:
227+
if not enable_scoring and len(scores) == 0:
228+
logger.info(
229+
"Skipping Discord role updates: scoring is disabled and persisted scores are empty; "
230+
"not applying score-based role changes to avoid stripping roles. "
231+
"Run with enable_scoring enabled once to populate scores, or keep role updates off."
232+
)
233+
else:
234+
apply_discord_roles(
235+
self.discord_writer,
236+
member_roles,
237+
scores,
238+
identity_mappings,
239+
self.config.role_mappings,
240+
policy,
241+
storage=self.storage,
242+
period_start=period_start,
243+
period_end=period_end,
244+
merge_role_rules=merge_role_rules,
245+
repo_contributor_roles=repo_contributor_roles,
246+
)
240247
else:
241248
logger.info("Discord role updates disabled by config (enable_discord_role_updates: false)")
242249

0 commit comments

Comments
 (0)