microsoft/graphrag · error · ValueError
DRIFT Search query cannot be empty.
Error message
DRIFT Search query cannot be empty.
What it means
DriftSearch.search validates up front that the query string is non-empty (query == "") and raises this ValueError otherwise. It is a simple input guard so the search pipeline never runs on an empty prompt.
Source
Thrown at packages/graphrag/graphrag/query/structured_search/drift_search/search.py:213
"""
Perform an asynchronous DRIFT search.
Args:
query (str): The query to search for.
conversation_history (Any, optional): The conversation history, if any.
reduce (bool, optional): Whether to reduce the response to a single comprehensive response.
Returns
-------
SearchResult: The search result containing the response and context data.
Raises
------
ValueError: If the query is empty.
"""
if query == "":
error_msg = "DRIFT Search query cannot be empty."
raise ValueError(error_msg)
llm_calls, prompt_tokens, output_tokens = {}, {}, {}
start_time = time.perf_counter()
# Check if query state is empty
if not self.query_state.graph:
# Prime the search with the primer
primer_context, token_ct = await self.context_builder.build_context(query)
llm_calls["build_context"] = token_ct["llm_calls"]
prompt_tokens["build_context"] = token_ct["prompt_tokens"]
output_tokens["build_context"] = token_ct["output_tokens"]
primer_response = await self.primer.search(
query=query, top_k_reports=primer_context
)
llm_calls["primer"] = primer_response.llm_calls
prompt_tokens["primer"] = primer_response.prompt_tokensView on GitHub (pinned to f40e9a26ce)
Solutions
- Validate the query is a non-empty, non-whitespace string before calling search
- Default to a meaningful placeholder or skip empty inputs in batch processing
- Strip and check the string: if not query.strip(): raise/skip in your own code first
Example fix
# before
result = await drift_search.aresolve(user_query) # user_query may be ''
# after
if not user_query or not user_query.strip():
raise ValueError('Query is required')
result = await drift_search.aresolve(user_query) Defensive patterns
Strategy: validation
Validate before calling
if not query or not query.strip():
raise ValueError("Query must be a non-empty string")
result = await drift_search.aresolve(query) Type guard
def is_valid_query(q) -> bool:
return isinstance(q, str) and len(q.strip()) > 0 Prevention
- Sanitize user input upstream (strip and reject blank strings)
- In batch pipelines, filter out empty rows before invoking search
When it happens
Trigger: Calling DriftSearch.search(''), DriftSearch.stream_search(''), or _search_step with an empty string, e.g. because a variable holding the user question was never set or was stripped to ''.
Common situations: Programmatic query loops where some rows of an input file have blank questions, frontends forwarding an empty input box, or whitespace-only strings that were stripped before the call.
Related errors
- No community reports available. Please provide a list of rep
- Query and document embeddings are not compatible. Please ens
- No intermediate answers found in primer response. Ensure tha
- No follow-up queries found in primer response. Ensure that t
- Response must be a list of dictionaries.
AI-assisted analysis of microsoft/graphrag@f40e9a26ce (2026-08-27).
Data as JSON: /api/errors/3a1f75112a713180.
Report an issue: GitHub.