{"record":{"id":"18e741d210357258","repo":"mem0ai/mem0","slug":"org-id-and-project-id-must-be-set-to-access-projec","errorCode":null,"errorMessage":"org_id and project_id must be set to access project operations","messagePattern":"org_id and project_id must be set to access project operations","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"mem0/client/project.py","lineNumber":83,"sourceCode":"    @property\n    def project_id(self) -> Optional[str]:\n        \"\"\"Get the project ID.\"\"\"\n        return self.config.project_id\n\n    @property\n    def user_email(self) -> Optional[str]:\n        \"\"\"Get the user email.\"\"\"\n        return self.config.user_email\n\n    def _validate_org_project(self) -> None:\n        \"\"\"\n        Validate that both org_id and project_id are set.\n\n        Raises:\n            ValueError: If org_id or project_id are not set.\n        \"\"\"\n        if not (self.config.org_id and self.config.project_id):\n            raise ValueError(\"org_id and project_id must be set to access project operations\")\n\n    def _prepare_params(self, kwargs: Optional[Dict[str, Any]] = None) -> Dict[str, Any]:\n        \"\"\"\n        Prepare query parameters for API requests.\n\n        Args:\n            kwargs: Additional keyword arguments.\n\n        Returns:\n            Dictionary containing prepared parameters.\n\n        Raises:\n            ValueError: If org_id or project_id validation fails.\n        \"\"\"\n        if kwargs is None:\n            kwargs = {}\n\n        # Add org_id and project_id if available","sourceCodeStart":65,"sourceCodeEnd":101,"githubUrl":"https://github.com/mem0ai/mem0/blob/001c235229be8795e3834520467bd0d661ed8f34/mem0/client/project.py#L65-L101","documentation":"Project operations in the Mem0 hosted client require BOTH an org_id and a project_id to be configured on the client. _validate_org_project() is the shared guard invoked by project-scoped methods, and it raises ValueError when either identifier is missing. This fails client-side before any network call.","triggerScenarios":"Instantiating a project client with only org_id (or only project_id) and then calling project-scoped methods such as project.get(), update(), delete(), list_members(), or add_member().","commonSituations":"Copying example code that constructs the client with an API key only; forgetting that project-level APIs need both IDs while memory APIs need neither; environment variables MEM0_ORG_ID / MEM0_PROJECT_ID not exported in the shell running the script.","solutions":["Construct the client with both identifiers: MemoryClient(api_key=..., org_id=..., project_id=...)","Set the MEM0_ORG_ID and MEM0_PROJECT_ID environment variables if the client reads config from env","Retrieve your org/project IDs from the Mem0 platform dashboard before instantiating the client"],"exampleFix":"# before\nclient = MemoryClient(api_key=API_KEY, project_id=\"p1\")\nclient.project.get()\n\n# after\nclient = MemoryClient(api_key=API_KEY, org_id=\"my-org\", project_id=\"p1\")\nclient.project.get()","handlingStrategy":"validation","validationCode":"if not (org_id and project_id):\n    raise ConfigError(\"project operations require both org_id and project_id\")\nclient = MemoryClient(api_key=API_KEY, org_id=org_id, project_id=project_id)","typeGuard":"def can_use_project_ops(cfg) -> bool:\n    return bool(getattr(cfg, \"org_id\", None) and getattr(cfg, \"project_id\", None))","tryCatchPattern":"try:\n    client.project.get()\nexcept ValueError as e:\n    if \"org_id and project_id\" in str(e):\n        raise ConfigError(\"set MEM0_ORG_ID and MEM0_PROJECT_ID\") from e\n    raise","preventionTips":["Assert both identifiers at app startup, before any client construction","Keep org_id/project_id in one validated settings object instead of scattering them"],"tags":["validation","hosted-api","projects","configuration"],"backgroundTag":null,"analyzedSha":"001c235229be8795e3834520467bd0d661ed8f34","analyzedAt":"2026-08-15T01:55:42.685Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}