{"record":{"id":"3d321de49e1ae648","repo":"HumanSignal/label-studio","slug":"cannot-find-bucket-bucket-name-in-s3","errorCode":null,"errorMessage":"Cannot find bucket {bucket_name} in S3","messagePattern":"Cannot find bucket (.+?) in S3","errorType":"validation","errorClass":"ValidationError","httpStatus":400,"severity":"error","filePath":"label_studio/io_storages/s3/serializers.py","lineNumber":69,"sourceCode":"        try:\n            storage.validate_connection()\n        except ParamValidationError:\n            raise ValidationError('Wrong credentials for S3 {bucket_name}'.format(bucket_name=storage.bucket))\n        except ClientError as e:\n            if (\n                e.response.get('Error').get('Code') in ['SignatureDoesNotMatch', '403']\n                or e.response.get('ResponseMetadata').get('HTTPStatusCode') == 403\n            ):\n                raise ValidationError(\n                    'Cannot connect to S3 {bucket_name} with specified AWS credentials'.format(\n                        bucket_name=storage.bucket\n                    )\n                )\n            if (\n                e.response.get('Error').get('Code') in ['NoSuchBucket', '404']\n                or e.response.get('ResponseMetadata').get('HTTPStatusCode') == 404\n            ):\n                raise ValidationError('Cannot find bucket {bucket_name} in S3'.format(bucket_name=storage.bucket))\n        except TypeError as e:\n            logger.info(f'It seems access keys are incorrect: {e}', exc_info=True)\n            raise ValidationError('It seems access keys are incorrect')\n        except KeyError:\n            raise ValidationError(f'{storage.url_scheme}://{storage.bucket}/{storage.prefix} not found.')\n        return data\n\n\nclass S3ImportStorageSerializer(S3StorageSerializerMixin, ImportStorageSerializer):\n    type = StorageTypeField(default=os.path.basename(os.path.dirname(__file__)))\n    presign = serializers.BooleanField(required=False, default=True)\n\n    def validate_s3_endpoint(self, value):\n        if value and settings.SSRF_PROTECTION_ENABLED:\n            validate_url_for_ssrf(value, block_local_urls=True)\n        return value\n\n    class Meta:","sourceCodeStart":51,"sourceCodeEnd":87,"githubUrl":"https://github.com/HumanSignal/label-studio/blob/0b49e9b53917880baf1dd85d574fe5541a9aafb2/label_studio/io_storages/s3/serializers.py#L51-L87","documentation":"In S3StorageSerializerMixin.validate(), a ClientError with code NoSuchBucket or HTTP 404 from validate_connection() is converted to 'Cannot find bucket {bucket_name} in S3'. The credentials worked but the named bucket does not exist in that region/account, or the endpoint points at the wrong S3-compatible service.","triggerScenarios":"Storage create/update where client.head_bucket / list_objects_v2 returns 404/NoSuchBucket — misspelled bucket, bucket in different region than the endpoint, or deleted bucket.","commonSituations":"Typo in bucket name; using an endpoint (e.g. custom s3_endpoint for MinIO) that hosts a different namespace; bucket deleted or never created; cross-region access where region_name doesn't match the bucket.","solutions":["Confirm the bucket exists: aws s3 ls | grep <bucket> (and in the right region).","Fix the bucket name or region_name in the storage payload.","If using a custom s3_endpoint, verify the S3-compatible server actually contains that bucket.","Recreate the bucket if it was deleted."],"exampleFix":"// before\n{\"bucket\": \"my-bucket-prod\"}  // bucket is actually my-bucket-prod-eu\n\n// after\n{\"bucket\": \"my-bucket-prod-eu\", \"region_name\": \"eu-west-1\"}","handlingStrategy":"validation","validationCode":"import boto3\nfrom botocore.exceptions import ClientError\n\ndef bucket_exists(bucket: str, region: str) -> bool:\n    s3 = boto3.client('s3', region_name=region)\n    try:\n        s3.head_bucket(Bucket=bucket)\n        return True\n    except ClientError as e:\n        code = int(e.response.get('ResponseMetadata', {}).get('HTTPStatusCode', 0))\n        if code == 404:\n            return False\n        raise\n\nassert bucket_exists('my-bucket', 'us-east-1'), 'Bucket does not exist in this region/account'","typeGuard":"def bucket_field_is_name(value) -> bool:\n    return isinstance(value, str) and value.islower() and '/' not in value","tryCatchPattern":"try:\n    serializer.is_valid(raise_exception=True)\nexcept ValidationError as e:\n    if 'Cannot find bucket' in str(e.detail):\n        # 404/NoSuchBucket: verify bucket name, region and endpoint","preventionTips":["Verify bucket existence and region with `aws s3api head-bucket --bucket <name>` first.","Match region_name to the bucket's actual region.","For MinIO/other S3-compatible servers, confirm the bucket exists on that server, not on AWS.","Guard against bucket deletion with lifecycle policies/alarms."],"tags":["s3","aws","not-found","bucket","serializer"],"backgroundTag":"s3-bucket-not-found","analyzedSha":"0b49e9b53917880baf1dd85d574fe5541a9aafb2","analyzedAt":"2026-08-29T00:39:52.578Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}