{"record":{"id":"607e566d11210210","repo":"mem0ai/mem0","slug":"please-provide-both-org-id-and-project-id","errorCode":null,"errorMessage":"Please provide both org_id and project_id","messagePattern":"Please provide both org_id and project_id","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"mem0/client/project.py","lineNumber":106,"sourceCode":"\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\n        if self.config.org_id and self.config.project_id:\n            kwargs[\"org_id\"] = self.config.org_id\n            kwargs[\"project_id\"] = self.config.project_id\n        elif self.config.org_id or self.config.project_id:\n            raise ValueError(\"Please provide both org_id and project_id\")\n\n        return {k: v for k, v in kwargs.items() if v is not None}\n\n    def _prepare_org_params(self, kwargs: Optional[Dict[str, Any]] = None) -> Dict[str, Any]:\n        \"\"\"\n        Prepare query parameters for organization-level 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 is not provided.\n        \"\"\"\n        if kwargs is None:\n            kwargs = {}","sourceCodeStart":88,"sourceCodeEnd":124,"githubUrl":"https://github.com/mem0ai/mem0/blob/001c235229be8795e3834520467bd0d661ed8f34/mem0/client/project.py#L88-L124","documentation":"When preparing query parameters, the project client accepts either both org_id and project_id or neither — supplying exactly one of them raises ValueError('Please provide both org_id and project_id'). This guard lives in _prepare_params() and runs before any HTTP request. It complements _validate_org_project by rejecting half-configured state.","triggerScenarios":"Calling any project method that builds params via _prepare_params() while the client config has org_id set but project_id missing (or vice versa). Also triggered if caller-supplied kwargs inject only one of the two keys.","commonSituations":"Setting MEM0_ORG_ID in CI but not MEM0_PROJECT_ID; instantiating the client from a partial config dict; refactors that drop one ID from a settings object while the other remains.","solutions":["Set both org_id and project_id on the client (or clear both to run org/user-level calls)","Check for half-configured env vars: one of MEM0_ORG_ID / MEM0_PROJECT_ID defined and the other missing","Fail fast at startup with an explicit assert on the config before creating the client"],"exampleFix":"# before\nclient = MemoryClient(api_key=API_KEY, org_id=\"my-org\")\nclient.project.get()  # ValueError\n\n# after\nclient = MemoryClient(api_key=API_KEY, org_id=\"my-org\", project_id=\"p1\")\nclient.project.get()","handlingStrategy":"validation","validationCode":"has_org = bool(cfg.org_id)\nhas_project = bool(cfg.project_id)\nif has_org != has_project:\n    raise ConfigError(\"org_id and project_id must be set together or both omitted\")","typeGuard":"def params_pair_complete(cfg) -> bool:\n    return bool(cfg.org_id) == bool(cfg.project_id)","tryCatchPattern":"try:\n    client.project.get()\nexcept ValueError as e:\n    if \"both org_id and project_id\" in str(e):\n        fix_config_ids()  # load both from secrets manager\n    raise","preventionTips":["Validate that the two IDs are either both present or both absent when loading config","Use one env var prefix per scope and lint for half-defined pairs in CI"],"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"}