{"record":{"id":"f8b1a6c33756d077","repo":"infiniflow/ragflow","slug":"101-f8b1a6","errorCode":"101","errorMessage":"Memory type must be a list.","messagePattern":"Memory type must be a list\\.","errorType":"validation","errorClass":"ArgumentException","httpStatus":400,"severity":"warning","filePath":"api/apps/services/memory_api_service.py","lineNumber":98,"sourceCode":"    :param memory_info: {\n        \"name\": str,\n        \"memory_type\": list[str],\n        \"embd_id\": str,\n        \"llm_id\": str,\n        \"tenant_embd_id\": str | None,\n        \"tenant_llm_id\": str | None\n    }\n    \"\"\"\n    # check name length\n    name = memory_info[\"name\"]\n    memory_name = name.strip()\n    if len(memory_name) == 0:\n        raise ArgumentException(\"Memory name cannot be empty or whitespace.\")\n    if len(memory_name) > MEMORY_NAME_LIMIT:\n        raise ArgumentException(f\"Memory name '{memory_name}' exceeds limit of {MEMORY_NAME_LIMIT}.\")\n    # check memory_type valid\n    if not isinstance(memory_info[\"memory_type\"], list):\n        raise ArgumentException(\"Memory type must be a list.\")\n    memory_type = set(memory_info[\"memory_type\"])\n    invalid_type = memory_type - {e.name.lower() for e in MemoryType}\n    if invalid_type:\n        raise ArgumentException(f\"Memory type '{invalid_type}' is not supported.\")\n    memory_type = list(memory_type)\n    success, res = MemoryService.create_memory(\n        tenant_id=current_user.id,\n        name=memory_name,\n        memory_type=memory_type,\n        embd_id=memory_info[\"embd_id\"],\n        llm_id=memory_info[\"llm_id\"],\n        tenant_embd_id=memory_info.get(\"tenant_embd_id\"),\n        tenant_llm_id=memory_info.get(\"tenant_llm_id\"),\n    )\n    if success:\n        return True, format_ret_data_from_memory(res)\n    else:\n        return False, res","sourceCodeStart":80,"sourceCodeEnd":116,"githubUrl":"https://github.com/infiniflow/ragflow/blob/554fb1133ac3861732235ad9c377eb5e0a770665/api/apps/services/memory_api_service.py#L80-L116","documentation":"Validation in create_memory: the 'memory_type' field must be a JSON array (Python list); passing a bare string, number, dict, or null raises ArgumentException before the type-value check runs. Valid elements are lowercased MemoryType enum names checked separately.","triggerScenarios":"POST create-memory with memory_type=\"\" or memory_type=\"LongTerm\" (a plain string instead of [\"LongTerm\"]), memory_type=null, or a dict like {\"type\": ...}.","commonSituations":"Clients sending a single type as a scalar because they only need one; JSON schemas that mark the field optional-string; copy-pasting examples from older API versions where the field was a string.","solutions":["Always send memory_type as an array, wrapping single values: [\"longterm\"]","Fix the client DTO/type so memory_type: string[] not string","Validate with Array.isArray(value) in JS / isinstance(x, list) in Python before the call"],"exampleFix":"# before\n{\"memory_type\": \"LongTerm\"}\n\n# after\n{\"memory_type\": [\"LongTerm\"]}","handlingStrategy":"type-guard","validationCode":"if not isinstance(payload.get(\"memory_type\"), list):\n    payload[\"memory_type\"] = [payload[\"memory_type\"]] if payload.get(\"memory_type\") else []","typeGuard":"def is_memory_type_list(v) -> bool:\n    return isinstance(v, list)","tryCatchPattern":null,"preventionTips":["Type the field as string[] in client schemas/DTOs","Always wrap single values in an array","Remember create rejects both non-list and unknown element values — fix shape first"],"tags":["memory","validation","create","type-validation"],"backgroundTag":null,"analyzedSha":"554fb1133ac3861732235ad9c377eb5e0a770665","analyzedAt":"2026-08-15T09:20:16.380Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}