mem0ai/mem0 · error · ValueError

Invalid {name}: cannot be empty or whitespace-only. Provide

Error message

Invalid {name}: cannot be empty or whitespace-only. Provide a valid identifier.

What it means

Error "Invalid {name}: cannot be empty or whitespace-only. Provide a valid identifier." thrown in mem0ai/mem0.

Source

Thrown at mem0/memory/main.py:202

        value: The entity ID value to validate
        name: The parameter name (for error messages)

    Returns:
        The trimmed entity ID, or None if input is None

    Raises:
        ValueError: If entity ID is invalid
    """
    if value is None:
        return None
    # Callers commonly pass integer ids (e.g. a database primary key). Coerce
    # to str at this single validation point so scoping stays consistent across
    # add/search/get_all/delete_all instead of crashing on `.strip()`.
    if not isinstance(value, str):
        value = str(value)
    trimmed = value.strip()
    if trimmed == "":
        raise ValueError(
            f"Invalid {name}: cannot be empty or whitespace-only. Provide a valid identifier."
        )
    if any(c.isspace() for c in trimmed):
        raise ValueError(
            f"Invalid {name}: cannot contain whitespace. Provide a valid identifier without spaces."
        )
    return trimmed


def _validate_search_params(threshold: Optional[float] = None, top_k: Optional[int] = None) -> None:
    """
    Validates search parameters.

    Args:
        threshold: Similarity threshold (must be between 0 and 1)
        top_k: Number of results to return (must be non-negative integer)

    Raises:

View on GitHub (pinned to 001c235229)

Solutions

  1. Provide a non-empty, non-whitespace identifier for the given parameter.

When it happens

Trigger: Thrown at mem0/memory/main.py:202 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/74dfbd730e216d89. Report an issue: GitHub.