{"record":{"id":"9b76fcfb75507afb","repo":"mem0ai/mem0","slug":"threshold-must-be-a-valid-number-9b76fc","errorCode":null,"errorMessage":"threshold must be a valid number","messagePattern":"threshold must be a valid number","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"mem0/memory/main.py","lineNumber":225,"sourceCode":"            f\"Invalid {name}: cannot contain whitespace. Provide a valid identifier without spaces.\"\n        )\n    return trimmed\n\n\ndef _validate_search_params(threshold: Optional[float] = None, top_k: Optional[int] = None) -> None:\n    \"\"\"\n    Validates search parameters.\n\n    Args:\n        threshold: Similarity threshold (must be between 0 and 1)\n        top_k: Number of results to return (must be non-negative integer)\n\n    Raises:\n        ValueError: If threshold or top_k are invalid\n    \"\"\"\n    if threshold is not None:\n        if not isinstance(threshold, (int, float)):\n            raise ValueError(\"threshold must be a valid number\")\n        if threshold < 0 or threshold > 1:\n            raise ValueError(\n                f\"Invalid threshold: {threshold}. Must be between 0 and 1 (inclusive).\"\n            )\n    if top_k is not None:\n        if not isinstance(top_k, int) or isinstance(top_k, bool):\n            raise ValueError(\"top_k must be a valid integer\")\n        if top_k < 0:\n            raise ValueError(\n                f\"Invalid top_k: {top_k}. Must be a non-negative integer.\"\n            )\n\n\ndef _validate_and_trim_search_query(query: str) -> str:\n    \"\"\"\n    Validates and normalizes a search query before embedding/vector search.\n\n    Raises:","sourceCodeStart":207,"sourceCodeEnd":243,"githubUrl":"https://github.com/mem0ai/mem0/blob/001c235229be8795e3834520467bd0d661ed8f34/mem0/memory/main.py#L207-L243","documentation":"Error \"threshold must be a valid number\" thrown in mem0ai/mem0.","triggerScenarios":"Thrown at mem0/memory/main.py:225 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass threshold as a number (int or float), not a string or other type."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"001c235229be8795e3834520467bd0d661ed8f34","analyzedAt":"2026-08-15T01:55:42.685Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}