infiniflow/ragflow · warning · ArgumentException

ARGUMENT_ERROR

ARGUMENT_ERROR

Error message

Memory name cannot be empty or whitespace.

What it means

Validation in create_memory: the 'name' field, after strip(), is empty. Names consisting only of whitespace (or empty strings) are rejected with ArgumentException (HTTP 400) before any row is inserted.

Source

Thrown at api/apps/services/memory_api_service.py:93

    return [memory for memory in MemoryService.get_by_ids(memory_ids) if _memory_accessible(memory)]


async def create_memory(memory_info: dict):
    """
    :param memory_info: {
        "name": str,
        "memory_type": list[str],
        "embd_id": str,
        "llm_id": str,
        "tenant_embd_id": str | None,
        "tenant_llm_id": str | None
    }
    """
    # check name length
    name = memory_info["name"]
    memory_name = name.strip()
    if len(memory_name) == 0:
        raise ArgumentException("Memory name cannot be empty or whitespace.")
    if len(memory_name) > MEMORY_NAME_LIMIT:
        raise ArgumentException(f"Memory name '{memory_name}' exceeds limit of {MEMORY_NAME_LIMIT}.")
    # check memory_type valid
    if not isinstance(memory_info["memory_type"], list):
        raise ArgumentException("Memory type must be a list.")
    memory_type = set(memory_info["memory_type"])
    invalid_type = memory_type - {e.name.lower() for e in MemoryType}
    if invalid_type:
        raise ArgumentException(f"Memory type '{invalid_type}' is not supported.")
    memory_type = list(memory_type)
    success, res = MemoryService.create_memory(
        tenant_id=current_user.id,
        name=memory_name,
        memory_type=memory_type,
        embd_id=memory_info["embd_id"],
        llm_id=memory_info["llm_id"],
        tenant_embd_id=memory_info.get("tenant_embd_id"),
        tenant_llm_id=memory_info.get("tenant_llm_id"),

View on GitHub (pinned to 554fb1133a)

Solutions

  1. Trim the name client-side and require non-empty before calling the API
  2. Give the input a sensible default name when the user leaves it blank
  3. Add form validation (required attribute) so the request never leaves the browser

Example fix

# before
create_memory({"name": " ", ...})

# after
name = raw_name.strip() or f"Memory-{date.today()}"
create_memory({"name": name, ...})
Defensive patterns

Strategy: validation

Validate before calling

name = (payload.get("name") or "").strip()
if not name:
    payload["name"] = f"Memory-{uuid4().hex[:8]}"

Type guard

def is_nonblank_name(v) -> bool:
    return isinstance(v, str) and len(v.strip()) > 0

Try / catch

try:
    create_memory(payload)
except ArgumentException as e:
    if "empty or whitespace" in str(e):
        payload["name"] = default_name()
        create_memory(payload)

Prevention

When it happens

Trigger: POST create-memory with name="", name=" ", or a name of only tabs/newlines. The value is stripped before the length check, so ' ' fails.

Common situations: Forms submitted without the name field populated; trimming done only client-side and bypassed by direct API calls; default empty-string values leaking from config objects.

Related errors


AI-assisted analysis of infiniflow/ragflow@554fb1133a (2026-08-15). Data as JSON: /api/errors/2d64c4318342581b. Report an issue: GitHub.