{"record":{"id":"4d4ed8aceace8328","repo":"remotion-dev/remotion","slug":"could-not-get-location-of-s3-bucket-q-w","errorCode":null,"errorMessage":"could not get location of S3 bucket %q: %w","messagePattern":"could not get location of S3 bucket %q: %w","errorType":"exception","errorClass":"error","httpStatus":null,"severity":"error","filePath":"packages/lambda-go/s3.go","lineNumber":87,"sourceCode":"\t\tconfig.WithRegion(region),\n\t)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"could not load AWS config: %w\", err)\n\t}\n\treturn s3.NewFromConfig(awsConfig, func(options *s3.Options) {\n\t\toptions.UsePathStyle = forcePathStyle\n\t}), nil\n}\n\n// isBucketInRegion reports whether the given bucket lives in region.\nfunc isBucketInRegion(svc bucketLocationGetter, bucket string, region string) (bool, error) {\n\tout, err := svc.GetBucketLocation(context.TODO(), &s3.GetBucketLocationInput{Bucket: new(bucket)})\n\tif err != nil {\n\t\tvar awsErr smithy.APIError\n\t\tif errors.As(err, &awsErr) && awsErr.ErrorCode() == \"NoSuchBucket\" {\n\t\t\treturn false, nil\n\t\t}\n\t\treturn false, fmt.Errorf(\"could not get location of S3 bucket %q: %w\", bucket, err)\n\t}\n\tlocation := string(out.LocationConstraint)\n\treturn location == region || (location == \"\" && region == regionUsEast1), nil\n}\n\n// getRemotionBuckets lists the Remotion buckets that exist in region.\nfunc getRemotionBuckets(svc *s3.Client, region string) ([]string, error) {\n\tout, err := svc.ListBuckets(context.TODO(), &s3.ListBucketsInput{})\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"could not list S3 buckets: %w\", err)\n\t}\n\tbuckets := []string{}\n\tfor _, bucket := range out.Buckets {\n\t\tname := aws.ToString(bucket.Name)\n\t\tif !strings.HasPrefix(name, bucketNamePrefix) {\n\t\t\tcontinue\n\t\t}\n\t\tisInRegion, err := isBucketInRegion(svc, name, region)","sourceCodeStart":69,"sourceCodeEnd":105,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/lambda-go/s3.go#L69-L105","documentation":"Returned by isBucketInRegion when GetBucketLocation fails for a reason other than NoSuchBucket (that one is swallowed and treated as 'not in region'). The %w carries the underlying AWS error. Most often this is a permissions issue: the caller can list bucket names but cannot call GetBucketLocation on a specific bucket.","triggerScenarios":"svc.GetBucketLocation returns a non-NoSuchBucket error — typically AccessDenied, PermanentRedirect (bucket in a different account/region requiring a different endpoint), or a transport error. The function re-raises the wrapped error.","commonSituations":"IAM policy grants s3:ListAllMyBuckets but not s3:GetBucketLocation. A `remotionlambda-` bucket exists in the account but was created by a different principal whose bucket policy denies the caller. Network egress to S3 is intermittent.","solutions":["Grant s3:GetBucketLocation on `arn:aws:s3:::*` in the caller's IAM policy.","Inspect the wrapped smithy.APIError code: AccessDenied → add the permission; AuthorizationHeaderMalformed → check endpoint/region; PermanentRedirect → bucket is in a different region.","If the bucket is foreign, delete it or migrate so only one Remotion-managed bucket remains."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"inRegion, err := isBucketInRegion(svc, name, region)\nif err != nil {\n    var awsErr smithy.APIError\n    if errors.As(err, &awsErr) && awsErr.ErrorCode() == \"AccessDenied\" {\n        // caller can list but not GetBucketLocation: add s3:GetBucketLocation\n    }\n    return err\n}","preventionTips":["Grant s3:GetBucketLocation on `arn:aws:s3:::*` in the caller's IAM policy.","Avoid leaving stale foreign `remotionlambda-` buckets in the account.","Test the IAM policy against a real bucket before deploying."],"tags":["aws","s3","iam","bucket","go","lambda-go"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}