{"record":{"id":"d51989f256e36184","repo":"floci-io/floci","slug":"s3bucketdoesnotexistexception","errorCode":"S3BucketDoesNotExistException","errorMessage":"S3 bucket name is required.","messagePattern":"S3 bucket name is required\\.","errorType":"exception","errorClass":"AwsException","httpStatus":400,"severity":"error","filePath":"src/main/java/io/github/hectorvent/floci/services/cloudtrail/CloudTrailService.java","lineNumber":66,"sourceCode":"    @Inject\n    public CloudTrailService(StorageFactory storageFactory, RegionResolver regionResolver,\n                             IamService iamService, ObjectMapper mapper) {\n        this.store = storageFactory.create(\"cloudtrail\", \"cloudtrail-trails.json\",\n                new TypeReference<Map<String, CloudTrailEntry>>() {});\n        this.regionResolver = regionResolver;\n        this.iamService = iamService;\n        this.mapper = mapper;\n    }\n\n    // --- Control plane ---\n\n    public Trail createTrail(String region, String name, String s3BucketName, String s3KeyPrefix,\n                             String snsTopicArn, boolean includeGlobalServiceEvents,\n                             boolean isMultiRegionTrail, boolean enableLogFileValidation,\n                             boolean isOrganizationTrail) {\n        validateTrailName(name);\n        if (s3BucketName == null || s3BucketName.isEmpty()) {\n            throw new AwsException(\"S3BucketDoesNotExistException\", \"S3 bucket name is required.\", 400);\n        }\n        String key = regionKey(region, name);\n        if (store.get(key).isPresent()) {\n            throw new AwsException(\"TrailAlreadyExistsException\",\n                    \"Trail \" + name + \" already exists.\", 400);\n        }\n        String arn = AwsArnUtils.Arn.of(\"cloudtrail\", region, regionResolver.getAccountId(),\n                \"trail/\" + name).toString();\n        Trail trail = new Trail(\n                name, arn, s3BucketName, s3KeyPrefix, snsTopicArn,\n                includeGlobalServiceEvents, isMultiRegionTrail, region,\n                enableLogFileValidation, false, false, isOrganizationTrail);\n        store.put(key, new CloudTrailEntry(trail, List.of(), false, null, null));\n        return trail;\n    }\n\n    public void deleteTrail(String region, String trailNameOrArn) {\n        Trail trail = findTrailOrThrow(region, trailNameOrArn);","sourceCodeStart":48,"sourceCodeEnd":84,"githubUrl":"https://github.com/floci-io/floci/blob/62ff490619e7bd3554597c28c704081b4c15add5/src/main/java/io/github/hectorvent/floci/services/cloudtrail/CloudTrailService.java#L48-L84","documentation":"Thrown by CreateTrail when S3BucketName is null or empty. CloudTrailService.createTrail validates the trail name first, then requires the bucket name, raising S3BucketDoesNotExistException. In real AWS the bucket must exist and permit CloudTrail writes; the emulator models only the required-name aspect with this code.","triggerScenarios":"CreateTrail without S3BucketName — e.g. `aws cloudtrail create-trail --name t` with no --s3-bucket-name; organizations trails created from templates where the bucket variable is unset.","commonSituations":"Terraform/CloudFormation templates referencing an undefined bucket parameter; refactoring that renames the bucket variable but not the assignment; assuming an organization trail can omit the bucket.","solutions":["Pass an S3BucketName in the CreateTrail request.","Create (or reference) the log-delivery bucket first and pass its exact name.","Validate required CreateTrail parameters locally before sending to surface which field is missing."],"exampleFix":"// before\nclient.createTrail(b -> b.name(\"audit\").build());\n\n// after\nclient.createTrail(b -> b.name(\"audit\").s3BucketName(\"my-cloudtrail-logs\").build());","handlingStrategy":"validation","validationCode":"if (s3BucketName == null || s3BucketName.isEmpty()) {\n    throw new IllegalArgumentException(\"CreateTrail requires S3BucketName\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    client.createTrail(req);\n} catch (S3BucketDoesNotExistException e) {\n    // bucket name missing or wrong: verify config and retry with the correct name\n}","preventionTips":["Validate required CreateTrail parameters (Name, S3BucketName) in one place before the call.","Reference the log bucket by exact name from your bucket inventory, not a guessed value."],"tags":["aws","cloudtrail","validation","s3","required-field"],"backgroundTag":null,"analyzedSha":"62ff490619e7bd3554597c28c704081b4c15add5","analyzedAt":"2026-08-14T14:25:23.764Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}