mem0ai/mem0 · error · ValueError

Invalid {name}: cannot contain whitespace. Provide a valid i

Error message

Invalid {name}: cannot contain whitespace. Provide a valid identifier without spaces.

What it means

Error "Invalid {name}: cannot contain whitespace. Provide a valid identifier without spaces." thrown in mem0ai/mem0.

Source

Thrown at mem0/memory/main.py:206

        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:
        ValueError: If threshold or top_k are invalid
    """
    if threshold is not None:
        if not isinstance(threshold, (int, float)):

View on GitHub (pinned to 001c235229)

Solutions

  1. Use an identifier without spaces (letters, digits, underscores/hyphens).

When it happens

Trigger: Thrown at mem0/memory/main.py:206 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/603adba532e4f309. Report an issue: GitHub.