mem0ai/mem0 · error · ValueError
Invalid query: must be a non-empty string.
Error message
Invalid query: must be a non-empty string.
What it means
Error "Invalid query: must be a non-empty string." thrown in mem0ai/mem0.
Source
Thrown at mem0/client/main.py:45
read_anon_ids,
setup_config,
)
from mem0.memory.telemetry import capture_client_event, client_telemetry
logger = logging.getLogger(__name__)
warnings.filterwarnings("default", category=DeprecationWarning)
# Setup user config
setup_config()
# Entity parameters that must be passed via filters, not top-level
ENTITY_PARAMS = frozenset({"user_id", "agent_id", "app_id", "run_id"})
def _validate_and_trim_search_query(query: str) -> str:
if not isinstance(query, str):
raise ValueError("Invalid query: must be a non-empty string.")
trimmed = query.strip()
if not trimmed:
raise ValueError("Invalid query: cannot be empty or whitespace-only.")
return trimmed
def _encode_path_segment(value: Any) -> str:
return quote(str(value), safe="")
def _maybe_alias_anon_to_email(user_email):
"""Fire $identify per prior anon ID so PostHog merges them into email.
Idempotent via telemetry.aliased_pairs: only writes markers when
telemetry is actually enabled, so disabling/re-enabling MEM0_TELEMETRY still works.
Best-effort: never raises.
"""
if client_telemetry.posthog is None:View on GitHub (pinned to 001c235229)
Solutions
- Pass a non-empty string as the query to search().
When it happens
Trigger: Thrown at mem0/client/main.py:45 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of mem0ai/mem0@001c235229 (2026-08-15).
Data as JSON: /api/errors/e6d77a516acf9c20.
Report an issue: GitHub.