{"record":{"id":"44000903b2c001ef","repo":"mem0ai/mem0","slug":"validation-002","errorCode":"VALIDATION_002","errorMessage":"Invalid 'memory_type'. Please pass {MemoryType.PROCEDURAL.value} to create procedural memories.","messagePattern":"Invalid 'memory_type'\\. Please pass (.+?) to create procedural memories\\.","errorType":"validation","errorClass":"Mem0ValidationError","httpStatus":null,"severity":"error","filePath":"mem0/memory/main.py","lineNumber":832,"sourceCode":"            LLMError: If LLM operations fail.\n            DatabaseError: If database operations fail.\n        \"\"\"\n        if timestamp is not None:\n            raise ValueError(get_temporal_feature_error_message(\"sync\", \"add\", \"timestamp\"))\n\n        normalized_expiration_date = _normalize_expiration_date(expiration_date)\n        temporal_usage_notice = detect_temporal_usage_from_metadata(metadata)\n        processed_metadata, effective_filters = _build_filters_and_metadata(\n            user_id=user_id,\n            agent_id=agent_id,\n            run_id=run_id,\n            input_metadata=metadata,\n        )\n        if normalized_expiration_date is not None:\n            processed_metadata[\"expiration_date\"] = normalized_expiration_date\n\n        if memory_type is not None and memory_type != MemoryType.PROCEDURAL.value:\n            raise Mem0ValidationError(\n                message=f\"Invalid 'memory_type'. Please pass {MemoryType.PROCEDURAL.value} to create procedural memories.\",\n                error_code=\"VALIDATION_002\",\n                details={\"provided_type\": memory_type, \"valid_type\": MemoryType.PROCEDURAL.value},\n                suggestion=f\"Use '{MemoryType.PROCEDURAL.value}' to create procedural memories.\"\n            )\n\n        if isinstance(messages, str):\n            messages = [{\"role\": \"user\", \"content\": messages}]\n\n        elif isinstance(messages, dict):\n            messages = [messages]\n\n        elif not isinstance(messages, list):\n            raise Mem0ValidationError(\n                message=\"messages must be str, dict, or list[dict]\",\n                error_code=\"VALIDATION_003\",\n                details={\"provided_type\": type(messages).__name__, \"valid_types\": [\"str\", \"dict\", \"list[dict]\"]},\n                suggestion=\"Convert your input to a string, dictionary, or list of dictionaries.\"","sourceCodeStart":814,"sourceCodeEnd":850,"githubUrl":"https://github.com/mem0ai/mem0/blob/001c235229be8795e3834520467bd0d661ed8f34/mem0/memory/main.py#L814-L850","documentation":"Raised as Mem0ValidationError (VALIDATION_002) by Memory.add() when memory_type is given and is anything other than 'procedural' (MemoryType.PROCEDURAL.value). In this SDK build, add() only accepts two cases: memory_type=None (default semantic memories) or memory_type='procedural' (workflow/skill memories tied to an agent_id). Values like 'semantic', 'episodic', or arbitrary strings are rejected because no other memory type is implemented on this path.","triggerScenarios":"m.add(msg, user_id='u1', memory_type='semantic') — assuming an explicit type must be named; memory_type='episodic' copied from platform docs; passing MemoryType.SOME_ENUM.name instead of .value; a typo like 'procedual'.","commonSituations":"Writing symmetric code that always passes memory_type for clarity; porting hosted-platform examples that enumerate multiple types; enum misuse passing the enum member where a different string is expected.","solutions":["Omit memory_type entirely for normal (semantic) memories — None is the default and valid.","Pass exactly memory_type='procedural' when creating procedural memories, and include agent_id since procedural memories are agent-scoped.","Import the enum and use MemoryType.PROCEDURAL.value instead of hardcoding strings.","Catch Mem0ValidationError and surface the embedded details (provided_type vs valid_type) in your API layer."],"exampleFix":"# before\nm.add(\"likes tea\", user_id=\"u1\", memory_type=\"semantic\")\n\n# after\nm.add(\"likes tea\", user_id=\"u1\")  # semantic is the default\n# procedural case:\nm.add(steps, agent_id=\"agent1\", memory_type=\"procedural\")","handlingStrategy":"validation","validationCode":"if memory_type is not None and memory_type != \"procedural\":\n    raise ValueError(\"memory_type must be 'procedural' or omitted\")","typeGuard":"def is_valid_memory_type(t) -> bool:\n    return t is None or t == \"procedural\"","tryCatchPattern":"from mem0.memory.utils import Mem0ValidationError\ntry:\n    m.add(msg, agent_id=\"a1\", memory_type=memory_type)\nexcept Mem0ValidationError as e:\n    if e.error_code == \"VALIDATION_002\":\n        return {\"error\": \"invalid memory_type\", \"valid\": \"procedural\"}\n    raise","preventionTips":["Omit memory_type for ordinary memories; the default is the semantic path.","Use MemoryType.PROCEDURAL.value rather than string literals.","Procedural memories require agent_id — pass it together with memory_type."],"tags":["validation","memory-type","add","procedural"],"backgroundTag":null,"analyzedSha":"001c235229be8795e3834520467bd0d661ed8f34","analyzedAt":"2026-08-15T01:55:42.685Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}