Skip to content

fix(query): ensure nodes missing level attributes are included in context#2333

Open
EaCognitive wants to merge 1 commit intomicrosoft:mainfrom
EaCognitive:fix-missing-node-attributes
Open

fix(query): ensure nodes missing level attributes are included in context#2333
EaCognitive wants to merge 1 commit intomicrosoft:mainfrom
EaCognitive:fix-missing-node-attributes

Conversation

@EaCognitive
Copy link
Copy Markdown

Fixes #1808

Problem

In GraphRAG's query engine, the _filter_under_community_level utility aggressively filters out any nodes that are missing the level attribute. This happens because pandas comparison df.level <= community_level returns False for NaN or None values, causing these nodes to be silently dropped from the query context. This leads to incomplete or hallucinated answers.

Solution

Updated the filtering logic to explicitly include nodes where the level attribute is NaN. This ensures that all relevant graph data is considered during query execution, regardless of metadata completeness.

Changes

  • packages/graphrag/graphrag/query/indexer_adapters.py: Updated _filter_under_community_level to handle NaN values gracefully.

Verification

  • Verified that the filter now uses a logical OR to preserve nodes with missing levels.

@EaCognitive EaCognitive requested a review from a team as a code owner April 21, 2026 21:59
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.

[Fatal Bug]: Nodes Missing Community and Level Attributes Are Excluded During Query Execution

1 participant