{"record":{"id":"3d08adc2c42128fb","repo":"mem0ai/mem0","slug":"filters-must-contain-at-least-one-of-user-id-age-3d08ad","errorCode":null,"errorMessage":"filters must contain at least one of: user_id, agent_id, run_id. Example: filters={'user_id': 'u1'}","messagePattern":"filters must contain at least one of: user_id, agent_id, run_id\\. Example: filters=(.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"mem0/memory/main.py","lineNumber":1304,"sourceCode":"\n        # Validate and trim entity IDs in filters\n        effective_filters = dict(filters) if filters else {}\n        if \"user_id\" in effective_filters:\n            effective_filters[\"user_id\"] = _validate_and_trim_entity_id(\n                effective_filters[\"user_id\"], \"user_id\"\n            )\n        if \"agent_id\" in effective_filters:\n            effective_filters[\"agent_id\"] = _validate_and_trim_entity_id(\n                effective_filters[\"agent_id\"], \"agent_id\"\n            )\n        if \"run_id\" in effective_filters:\n            effective_filters[\"run_id\"] = _validate_and_trim_entity_id(\n                effective_filters[\"run_id\"], \"run_id\"\n            )\n\n        # Validate filters contains at least one entity ID\n        if not any(key in effective_filters for key in (\"user_id\", \"agent_id\", \"run_id\")):\n            raise ValueError(\n                \"filters must contain at least one of: user_id, agent_id, run_id. \"\n                \"Example: filters={'user_id': 'u1'}\"\n            )\n\n        limit = top_k\n        fetch_limit = limit if show_expired else max(limit * 4, 60)\n        scale_threshold_notice = detect_scale_threshold_from_top_k(top_k)\n\n        keys, encoded_ids = process_telemetry_filters(effective_filters)\n        capture_event(\n            \"mem0.get_all\", self, {\"limit\": limit, \"keys\": keys, \"encoded_ids\": encoded_ids, \"sync_type\": \"sync\"}\n        )\n\n        all_memories_result = self._get_all_from_vector_store(effective_filters, fetch_limit, show_expired, limit)\n\n        if scale_threshold_notice:\n            display_scale_threshold_notice(self, \"sync\", \"get_all\", *scale_threshold_notice)\n        else:","sourceCodeStart":1286,"sourceCodeEnd":1322,"githubUrl":"https://github.com/mem0ai/mem0/blob/001c235229be8795e3834520467bd0d661ed8f34/mem0/memory/main.py#L1286-L1322","documentation":"Raised as a plain ValueError by Memory.get_all() when the filters dict contains none of user_id, agent_id, or run_id. Unlike add(), get_all() takes scoping only through its filters argument, so an empty filters dict or one containing only non-entity keys (e.g. {'category':'preference'}) is rejected — listing every memory in the store with no actor scope is not allowed in the OSS SDK.","triggerScenarios":"m.get_all() with no filters at all; m.get_all(filters={'category':'work'}) forgetting the user; building filters conditionally so the user_id key is dropped when a variable is None: filters={'user_id': user_id} with user_id=None still contains the key but yields None (key present passes this check but fails later trimming) — the fully empty case comes from filters={} or filters=None plus no scope; using top-level user_id= kwarg which is rejected earlier by _reject_top_level_entity_params.","commonSituations":"Admin dashboards intending to list 'all' memories; refactoring from search(user_id=...) positional style to the filters dict and losing the ID; multi-tenant code where the tenant key is occasionally missing.","solutions":["Pass the scope in filters: m.get_all(filters={'user_id': 'u1'}) (or agent_id/run_id).","Do not pass user_id as a top-level keyword to get_all — it is rejected; it must live inside filters.","If you truly need every memory, iterate your known user/agent IDs and union the results.","Guard in your wrapper: raise a clear error when no entity ID is available instead of calling get_all anyway."],"exampleFix":"# before\nmems = m.get_all(filters={\"category\": \"work\"})\n\n# after\nmems = m.get_all(filters={\"user_id\": \"u1\", \"category\": \"work\"})","handlingStrategy":"validation","validationCode":"ENTITY_KEYS = (\"user_id\", \"agent_id\", \"run_id\")\nfilters = filters or {}\nif not any(k in filters and filters[k] for k in ENTITY_KEYS):\n    raise ValueError(\"get_all requires user_id/agent_id/run_id inside filters\")","typeGuard":"def has_entity_filter(filters) -> bool:\n    return any(filters.get(k) for k in (\"user_id\", \"agent_id\", \"run_id\"))","tryCatchPattern":null,"preventionTips":["Always build filters with a scope key first: filters = {'user_id': uid} then add extras.","Remember get_all() has no top-level user_id kwarg — filters only.","For 'list everything', iterate known IDs rather than calling unscoped."],"tags":["validation","get-all","filters","scoping"],"backgroundTag":null,"analyzedSha":"001c235229be8795e3834520467bd0d661ed8f34","analyzedAt":"2026-08-15T01:55:42.685Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}