{"record":{"id":"94d5a4d9bc75e5db","repo":"mem0ai/mem0","slug":"aws-credentials-not-found-please-set-aws-access-k","errorCode":null,"errorMessage":"AWS credentials not found. Please set AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, and AWS_REGION environment variables, or provide them in the config.","messagePattern":"AWS credentials not found\\. Please set AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, and AWS_REGION environment variables, or provide them in the config\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"critical","filePath":"mem0/llms/aws_bedrock.py","lineNumber":95,"sourceCode":"        self.model_config = self.config.get_model_config()\n        self.provider = extract_provider(self.config.model, self.config.provider_override)\n\n        # Initialize provider-specific settings\n        self._initialize_provider_settings()\n\n    def _initialize_aws_client(self):\n        \"\"\"Initialize AWS Bedrock client with proper credentials.\"\"\"\n        try:\n            aws_config = self.config.get_aws_config()\n\n            # Create Bedrock runtime client\n            self.client = boto3.client(\"bedrock-runtime\", **aws_config)\n\n            # Test connection\n            self._test_connection()\n\n        except NoCredentialsError:\n            raise ValueError(\n                \"AWS credentials not found. Please set AWS_ACCESS_KEY_ID, \"\n                \"AWS_SECRET_ACCESS_KEY, and AWS_REGION environment variables, \"\n                \"or provide them in the config.\"\n            )\n        except ClientError as e:\n            if e.response[\"Error\"][\"Code\"] == \"UnauthorizedOperation\":\n                raise ValueError(\n                    f\"Unauthorized access to Bedrock. Please ensure your AWS credentials \"\n                    f\"have permission to access Bedrock in region {self.config.aws_region}.\"\n                )\n            else:\n                raise ValueError(f\"AWS Bedrock error: {e}\")\n\n    def _test_connection(self):\n        \"\"\"Test connection to AWS Bedrock service.\"\"\"\n        try:\n            # List available models to test connection\n            bedrock_client = boto3.client(\"bedrock\", **self.config.get_aws_config())","sourceCodeStart":77,"sourceCodeEnd":113,"githubUrl":"https://github.com/mem0ai/mem0/blob/001c235229be8795e3834520467bd0d661ed8f34/mem0/llms/aws_bedrock.py#L77-L113","documentation":"Raised by AWSBedrockLLM._initialize_aws_client when boto3 raises NoCredentialsError while creating the bedrock-runtime client — no credentials were discoverable via config, env vars, or the default credential chain, and the test connection fails. It is a config/environment error surfaced as ValueError at LLM construction time.","triggerScenarios":"No AWS_ACCESS_KEY_ID/AWS_SECRET_ACCESS_KEY env vars, no aws config keys in the mem0 LLM config, and no IAM role or ~/.aws/credentials on the host; running locally without aws configure having been run; container missing the mounted credentials","commonSituations":"Local development without AWS CLI setup; ECS/EKS task role misconfigured or missing; expired SSO session (aws sso login needed); CI runner with no AWS auth step.","solutions":["Run aws configure (or set AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_REGION env vars)","Or pass aws_access_key_id/aws_secret_access_key/aws_region in the mem0 LLM config","On AWS compute, attach an IAM execution/task role with bedrock:InvokeModel and remove stale env credential overrides","For SSO, re-authenticate: aws sso login --profile <profile> and export AWS_PROFILE"],"exampleFix":"// before\nMemory.from_config({\"llm\": {\"provider\": \"aws_bedrock\"}})  # ValueError: credentials not found\n\n# after\nMemory.from_config({\"llm\": {\"provider\": \"aws_bedrock\", \"config\": {\n    \"aws_access_key_id\": \"...\", \"aws_secret_access_key\": \"...\", \"aws_region\": \"us-east-1\"\n}}})","handlingStrategy":"validation","validationCode":"import os\n\ndef aws_creds_available(cfg) -> bool:\n    if cfg.get(\"aws_access_key_id\") and cfg.get(\"aws_secret_access_key\"):\n        return True\n    return bool(os.getenv(\"AWS_ACCESS_KEY_ID\") and os.getenv(\"AWS_SECRET_ACCESS_KEY\")) or \\\n           os.path.isfile(os.path.expanduser(\"~/.aws/credentials\"))","typeGuard":null,"tryCatchPattern":"try:\n    llm = AWSBedrockLLM(config)\nexcept ValueError as e:\n    if \"AWS credentials not found\" in str(e):\n        raise SystemExit(\"Configure AWS creds: aws configure or env vars\") from e\n    raise","preventionTips":["Run aws configure or set AWS_* env vars before starting mem0","On AWS compute, attach an IAM role and avoid stale env-var creds","Health-check credential resolution at startup in containers"],"tags":["python","aws","bedrock","credentials","iam","configuration","mem0"],"backgroundTag":null,"analyzedSha":"001c235229be8795e3834520467bd0d661ed8f34","analyzedAt":"2026-08-15T01:55:42.685Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}