Skip to content

Handle missing root communities in dynamic selection - #2413

Closed
Yin Li (yinli-systems) wants to merge 1 commit into
microsoft:mainfrom
yinli-systems:kevin/dynamic-community-missing-root
Closed

Yin Li (yinli-systems) wants to merge 1 commit into
microsoft:mainfrom
yinli-systems:kevin/dynamic-community-missing-root

Conversation

@yinli-systems

Copy link
Copy Markdown

Summary

Fixes #2382 by allowing DynamicCommunitySelection to initialize when the community hierarchy has no level 0 entries. In that case there are no root communities to seed the dynamic traversal, so the selector now starts with an empty queue instead of raising KeyError during construction.

Tests

  • git diff --check
  • PYTHONPYCACHEPREFIX=/private/tmp/graphrag-pycache /usr/bin/python3 -m py_compile packages/graphrag/graphrag/query/context_builder/dynamic_community_selection.py tests/unit/query/context_builder/dynamic_community_selection.py
  • UV_CACHE_DIR=/private/tmp/uv-cache-graphrag uv run ruff check packages/graphrag/graphrag/query/context_builder/dynamic_community_selection.py tests/unit/query/context_builder/dynamic_community_selection.py
  • UV_CACHE_DIR=/private/tmp/uv-cache-graphrag uv run ruff format --check packages/graphrag/graphrag/query/context_builder/dynamic_community_selection.py tests/unit/query/context_builder/dynamic_community_selection.py
  • UV_CACHE_DIR=/private/tmp/uv-cache-graphrag PYTHONPATH=packages/graphrag uv run --package graphrag pytest -q tests/unit/query/context_builder/dynamic_community_selection.py

@yinli-systems
Yin Li (yinli-systems) requested a review from a team as a code owner June 23, 2026 12:38
@yinli-systems

Copy link
Copy Markdown
Author

Closing after re-auditing the maintainer guidance on #2382 and the earlier #2384. Treating a missing level-0 community as an empty traversal would mask an indexing invariant violation, which Nathan Evans (@natoverse) explicitly identified as the more serious underlying problem. This PR therefore should not merge in its current direction.

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.

DynamicCommunitySelection crashes with KeyError when no communities at level 0

1 participant