Skip to content

fix: preserve entities without community assignment in _filter_under_community_level (#2348)#2371

Open
hanhan761 wants to merge 1 commit into
microsoft:mainfrom
hanhan761:fix-2348-nan-filter-v2
Open

fix: preserve entities without community assignment in _filter_under_community_level (#2348)#2371
hanhan761 wants to merge 1 commit into
microsoft:mainfrom
hanhan761:fix-2348-nan-filter-v2

Conversation

@hanhan761
Copy link
Copy Markdown

Summary

Fix #2348: _filter_under_community_level() uses df.level <= community_level which evaluates to False for NaN values, silently dropping all entities that were not assigned to any community during Leiden community detection. This causes CLI query commands to operate on a drastically reduced entity set with no warning.

Changes

In graphrag/query/indexer_adapters.py:

  • Added | df.level.isna() to the filter condition so entities without community assignment are preserved
  • Added None handling for community_level parameter so callers can bypass the filter

Issue

Fixes #2348

…community_level (microsoft#2348)

_filter_under_community_level uses df.level <= community_level which evaluates to False for NaN values, silently dropping all entities that were not assigned to any community during Leiden detection. Fix by adding df.level.isna() to the filter condition.

Also add None handling for community_level parameter so callers can bypass the filter entirely.
@hanhan761 hanhan761 requested a review from a team as a code owner May 30, 2026 08:39
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.

_filter_under_community_level silently drops all entities without community assignments due to NaN comparison

1 participant