Skip to content

Conversation

@KeonhoChu
Copy link

@KeonhoChu KeonhoChu commented Nov 10, 2025

Description

Fixes a type mismatch bug in DynamicCommunitySelection that prevented the algorithm from correctly traversing child communities during global search queries with dynamic_community_selection=True.

Related Issues

Fixes #2004

Proposed Changes

  • Fixed type mismatch in dynamic_community_selection.py (lines 125-129)
    • Child community IDs from self.communities[community].children were not matching keys in self.reports dictionary due to type inconsistency
    • Added explicit string conversion (str(child)) to ensure child IDs match the self.reports key type
    • Added explanatory comment for clarity

Root Cause:

  • Community.children contains IDs that may be loaded as integers
  • CommunityReport.community_id is defined as str type
  • self.reports dictionary is keyed by community_id (strings)
  • The membership test if child in self.reports always failed, causing all child communities to be skipped

Impact:

  • Before fix: Only 10 out of 5,586 communities were referenced (stuck at level 0)
  • After fix: 309 out of 5,586 communities are correctly traversed across multiple levels

Checklist

  • [v] I have tested these changes locally (unit tests pass)
  • [v] I have reviewed the code changes
  • [v] I have updated the documentation (added inline comment explaining the fix)
  • [v] I have added a semversioner changeset (patch level)

@KeonhoChu KeonhoChu requested a review from a team as a code owner November 10, 2025 01:03
@KeonhoChu KeonhoChu closed this Nov 10, 2025
@KeonhoChu KeonhoChu reopened this Nov 10, 2025
@KeonhoChu
Copy link
Author

@microsoft-github-policy-service agree

@KeonhoChu KeonhoChu closed this Nov 12, 2025
@KeonhoChu KeonhoChu reopened this Nov 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: DynamicCommunitySelection skips child communities because children IDs are int while self.reports keys are str

1 participant