{"record":{"id":"7987917b38977ee9","repo":"mem0ai/mem0","slug":"google-application-credentials-json-is-not-provide","errorCode":null,"errorMessage":"Google application credentials JSON is not provided. Please provide a valid JSON path or set the 'GOOGLE_APPLICATION_CREDENTIALS' environment variable.","messagePattern":"Google application credentials JSON is not provided\\. Please provide a valid JSON path or set the 'GOOGLE_APPLICATION_CREDENTIALS' environment variable\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"critical","filePath":"mem0/embeddings/vertexai.py","lineNumber":38,"sourceCode":"            \"update\": self.config.memory_update_embedding_type or \"RETRIEVAL_DOCUMENT\",\n            \"search\": self.config.memory_search_embedding_type or \"RETRIEVAL_QUERY\",\n        }\n\n        # Set up authentication using centralized GCP authenticator\n        # This supports multiple authentication methods while preserving environment variable support\n        try:\n            GCPAuthenticator.setup_vertex_ai(\n                service_account_json=getattr(self.config, 'google_service_account_json', None),\n                credentials_path=self.config.vertex_credentials_json,\n                project_id=getattr(self.config, 'google_project_id', None)\n            )\n        except Exception:\n            # Fall back to original behavior for backward compatibility\n            credentials_path = self.config.vertex_credentials_json\n            if credentials_path:\n                os.environ[\"GOOGLE_APPLICATION_CREDENTIALS\"] = credentials_path\n            elif not os.getenv(\"GOOGLE_APPLICATION_CREDENTIALS\"):\n                raise ValueError(\n                    \"Google application credentials JSON is not provided. Please provide a valid JSON path or set the 'GOOGLE_APPLICATION_CREDENTIALS' environment variable.\"\n                )\n\n        self.model = TextEmbeddingModel.from_pretrained(self.config.model)\n\n    def embed(self, text, memory_action: Optional[Literal[\"add\", \"search\", \"update\"]] = None):\n        \"\"\"\n        Get the embedding for the given text using Vertex AI.\n\n        Args:\n            text (str): The text to embed.\n            memory_action (optional): The type of embedding to use. Must be one of \"add\", \"search\", or \"update\". Defaults to None.\n        Returns:\n            list: The embedding vector.\n        \"\"\"\n        embedding_type = \"SEMANTIC_SIMILARITY\"\n        if memory_action is not None:\n            if memory_action not in self.embedding_types:","sourceCodeStart":20,"sourceCodeEnd":56,"githubUrl":"https://github.com/mem0ai/mem0/blob/001c235229be8795e3834520467bd0d661ed8f34/mem0/embeddings/vertexai.py#L20-L56","documentation":"Raised by VertexAIEmbedding.__init__ when Google credentials cannot be established: the GCPAuthenticator setup raised, no vertex_credentials_json path exists in config, and the GOOGLE_APPLICATION_CREDENTIALS env var is unset. It is the terminal fallback after both programmatic and environment-based credential discovery failed.","triggerScenarios":"Initializing VertexAIEmbedding with no google_service_account_json, no vertex_credentials_json, and no GOOGLE_APPLICATION_CREDENTIALS env var; or when the authenticator path raised (malformed service-account JSON) and the fallback also found nothing","commonSituations":"Running mem0 in a container/CI without mounting the GCP key; assuming gcloud application-default credentials are enough (this code path wants a service-account JSON specifically); a typo in the credentials file path in the embedder config.","solutions":["Set vertex_credentials_json in the embedder config to the path of a service-account JSON file with Vertex AI User permission","Or export GOOGLE_APPLICATION_CREDENTIALS=/path/to/key.json before starting the process","Or pass google_service_account_json (dict) plus google_project_id in the config so GCPAuthenticator resolves them programmatically","Verify the JSON file exists and parses: python -c \"import json;json.load(open('key.json'))\"; ensure the Vertex AI API is enabled in the project"],"exampleFix":"// before\nMemory.from_config({\"embedder\": {\"provider\": \"vertexai\"}})  # ValueError: credentials not provided\n\n# after\nMemory.from_config({\"embedder\": {\"provider\": \"vertexai\", \"config\": {\n    \"model\": \"text-embedding-004\",\n    \"vertex_credentials_json\": \"/secrets/gcp-sa.json\"\n}}})","handlingStrategy":"validation","validationCode":"import json, os\n\ndef gcp_ready(cfg) -> bool:\n    sa = cfg.get(\"google_service_account_json\")\n    path = cfg.get(\"vertex_credentials_json\")\n    if sa and cfg.get(\"google_project_id\"):\n        return True\n    if path and os.path.isfile(path):\n        json.load(open(path))  # raises early on malformed JSON\n        return True\n    return bool(os.getenv(\"GOOGLE_APPLICATION_CREDENTIALS\"))\n\nassert gcp_ready(embedder_config), \"no usable GCP credentials found\"","typeGuard":null,"tryCatchPattern":"try:\n    embedder = VertexAIEmbedding(config)\nexcept ValueError as e:\n    if \"credentials\" in str(e).lower():\n        raise SystemExit(\"Set vertex_credentials_json or GOOGLE_APPLICATION_CREDENTIALS\") from e\n    raise","preventionTips":["Mount the service-account JSON in containers and set the env var explicitly","Validate the JSON parses before starting mem0","Run a startup credential check for GCP-backed providers"],"tags":["python","gcp","vertexai","credentials","configuration","mem0"],"backgroundTag":null,"analyzedSha":"001c235229be8795e3834520467bd0d661ed8f34","analyzedAt":"2026-08-15T01:55:42.685Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}