{"record":{"id":"9a32954206f93130","repo":"mem0ai/mem0","slug":"no-valid-gcp-credentials-found-please-provide-one","errorCode":null,"errorMessage":"No valid GCP credentials found. Please provide one of:\n1. service_account_json parameter (dict)\n2. credentials_path parameter (file path)\n3. GOOGLE_APPLICATION_CREDENTIALS environment variable\n4. Default credentials (if running on GCP)\nError: {e}","messagePattern":"No valid GCP credentials found\\. Please provide one of:\n1\\. service_account_json parameter \\(dict\\)\n2\\. credentials_path parameter \\(file path\\)\n3\\. GOOGLE_APPLICATION_CREDENTIALS environment variable\n4\\. Default credentials \\(if running on GCP\\)\nError: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"mem0/utils/gcp_auth.py","lineNumber":81,"sourceCode":"\n        # Method 3: Environment variable path\n        elif os.getenv(\"GOOGLE_APPLICATION_CREDENTIALS\"):\n            env_path = os.getenv(\"GOOGLE_APPLICATION_CREDENTIALS\")\n            if os.path.isfile(env_path):\n                credentials = service_account.Credentials.from_service_account_file(\n                    env_path, scopes=scopes\n                )\n                # Extract project_id from the file\n                with open(env_path, 'r') as f:\n                    cred_data = json.load(f)\n                    project_id = cred_data.get(\"project_id\")\n\n        # Method 4: Default credentials (GCE, Cloud Run, etc.)\n        if not credentials:\n            try:\n                credentials, project_id = default(scopes=scopes)\n            except Exception as e:\n                raise ValueError(\n                    f\"No valid GCP credentials found. Please provide one of:\\n\"\n                    f\"1. service_account_json parameter (dict)\\n\"\n                    f\"2. credentials_path parameter (file path)\\n\"\n                    f\"3. GOOGLE_APPLICATION_CREDENTIALS environment variable\\n\"\n                    f\"4. Default credentials (if running on GCP)\\n\"\n                    f\"Error: {e}\"\n                )\n\n        return credentials, project_id\n\n    @staticmethod\n    def setup_vertex_ai(\n        service_account_json: Optional[Dict[str, Any]] = None,\n        credentials_path: Optional[str] = None,\n        project_id: Optional[str] = None,\n        location: str = \"us-central1\"\n    ) -> str:\n        \"\"\"","sourceCodeStart":63,"sourceCodeEnd":99,"githubUrl":"https://github.com/mem0ai/mem0/blob/001c235229be8795e3834520467bd0d661ed8f34/mem0/utils/gcp_auth.py#L63-L99","documentation":"Raised by GCPAuthenticator.get_credentials after all four credential strategies failed: (1) service_account_json dict, (2) credentials_path file, (3) GOOGLE_APPLICATION_CREDENTIALS env var, (4) google.auth.default() for GCE/Cloud Run/Workload Identity. The trailing 'Error: {e}' carries the underlying google.auth.default() exception, which usually names the real problem (no ADC file, metadata server unreachable, etc.).","triggerScenarios":"Running locally with no service account JSON supplied and no GOOGLE_APPLICATION_CREDENTIALS set and ~/.config/gcloud/application_default_credentials.json absent; ADC pointing at a deleted/rotated key file; running outside GCP while assuming default credentials exist; blocked metadata server (169.254.169.254) causing google.auth.default() to time out.","commonSituations":"New developer machine without gcloud auth application-default login; CI runner lacking the secret mount; expired service account key; firewall/proxy blocking the GCE metadata endpoint; Workload Identity not configured on the GKE/EKS node.","solutions":["Run gcloud auth application-default login for local development","Or set GOOGLE_APPLICATION_CREDENTIALS=/path/to/key.json with a valid service account key","Or pass service_account_json=... / credentials_path=... directly in the provider config","On GCP compute, verify Workload Identity / attached service account is configured","Read the trailing 'Error:' text — it distinguishes missing file vs unreachable metadata server vs malformed key"],"exampleFix":"# before\nmemory = Memory.from_config({\"embedder\": {\"provider\": \"vertexai\", \"config\": {}}})\n# ValueError: No valid GCP credentials found ...\n\n# after\n# gcloud auth application-default login\nmemory = Memory.from_config({\"embedder\": {\"provider\": \"vertexai\", \"config\": {}}})","handlingStrategy":"try-catch","validationCode":"import os, pathlib\nADC = pathlib.Path.home() / '.config/gcloud/application_default_credentials.json'\ndef gcp_creds_likely_present():\n    return bool(os.getenv('GOOGLE_APPLICATION_CREDENTIALS') or os.getenv('GCP_SERVICE_ACCOUNT_JSON') or ADC.exists())","typeGuard":null,"tryCatchPattern":"try:\n    creds, project = GCPAuthenticator.get_credentials(scopes=[...])\nexcept ValueError as e:\n    if 'No valid GCP credentials found' in str(e):\n        raise ConfigError('run gcloud auth application-default login or set GOOGLE_APPLICATION_CREDENTIALS') from e\n    raise","preventionTips":["Run gcloud auth application-default login as part of dev-machine setup","Pass service_account_json explicitly in production configs instead of relying on ADC","Add a startup health check that calls get_credentials once at boot","Alert on credential-expiry events for rotated service-account keys"],"tags":["gcp","authentication","credentials","configuration"],"backgroundTag":null,"analyzedSha":"001c235229be8795e3834520467bd0d661ed8f34","analyzedAt":"2026-08-15T01:55:42.685Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}