Description
DynamicCommunitySelection.__init__ at dynamic_community_selection.py:71 accesses self.levels["0"] directly without checking whether the key exists. If the input data contains no communities at level "0" (e.g., all communities start at level "1" or the communities list is empty), this raises KeyError: '0' and crashes the dynamic community selection flow.
Root Cause
# line 71
self.starting_communities = self.levels["0"]
self.levels is built from the communities list at lines 62-68. If no community has level="0", the key "0" is never added to the dict.
Expected Behavior
When no communities exist at level 0, starting_communities should default to an empty list ([]) so the selection gracefully yields no results instead of crashing.
Proposed Fix
Replace self.levels["0"] with self.levels.get("0", []) on line 71.
Impact
This affects users of the dynamic community selection feature (used in DRIFT search) when their indexed data has no root-level communities, which can happen with small or domain-specific datasets.
Description
DynamicCommunitySelection.__init__atdynamic_community_selection.py:71accessesself.levels["0"]directly without checking whether the key exists. If the input data contains no communities at level "0" (e.g., all communities start at level "1" or the communities list is empty), this raisesKeyError: '0'and crashes the dynamic community selection flow.Root Cause
self.levelsis built from the communities list at lines 62-68. If no community haslevel="0", the key "0" is never added to the dict.Expected Behavior
When no communities exist at level 0,
starting_communitiesshould default to an empty list ([]) so the selection gracefully yields no results instead of crashing.Proposed Fix
Replace
self.levels["0"]withself.levels.get("0", [])on line 71.Impact
This affects users of the dynamic community selection feature (used in DRIFT search) when their indexed data has no root-level communities, which can happen with small or domain-specific datasets.