{"record":{"id":"1de3ae6b09c1bdbb","repo":"floci-io/floci","slug":"invalidtrailnameexception","errorCode":"InvalidTrailNameException","errorMessage":"Trail name is required.","messagePattern":"Trail name is required\\.","errorType":"exception","errorClass":"AwsException","httpStatus":400,"severity":"error","filePath":"src/main/java/io/github/hectorvent/floci/services/cloudtrail/CloudTrailService.java","lineNumber":472,"sourceCode":"        }\n        // Name → region-scoped only (AWS resolves a name only in the current Region)\n        return store.get(regionKey(region, nameOrArn))\n                .map(CloudTrailEntry::trail)\n                .orElse(null);\n    }\n\n    private Trail findTrailOrThrow(String region, String nameOrArn) {\n        Trail t = findTrail(region, nameOrArn);\n        if (t == null) {\n            throw new AwsException(\"TrailNotFoundException\",\n                    \"Unknown trail: \" + nameOrArn, 400);\n        }\n        return t;\n    }\n\n    private static void validateTrailName(String name) {\n        if (name == null || name.isEmpty()) {\n            throw new AwsException(\"InvalidTrailNameException\", \"Trail name is required.\", 400);\n        }\n        if (name.length() < 3) {\n            throw new AwsException(\"InvalidTrailNameException\",\n                    \"Trail name too short. Minimum allowed length: 3 characters.\", 400);\n        }\n        if (name.length() > 128) {\n            throw new AwsException(\"InvalidTrailNameException\",\n                    \"Trail name too long. Maximum allowed length: 128 characters.\", 400);\n        }\n        if (!Character.isLetterOrDigit(name.charAt(0))) {\n            throw new AwsException(\"InvalidTrailNameException\",\n                    \"Trail name must starts with a letter or number.\", 400);\n        }\n        if (!Character.isLetterOrDigit(name.charAt(name.length() - 1))) {\n            throw new AwsException(\"InvalidTrailNameException\",\n                    \"Trail name must end with a letter or number.\", 400);\n        }\n        for (char c : name.toCharArray()) {","sourceCodeStart":454,"sourceCodeEnd":490,"githubUrl":"https://github.com/floci-io/floci/blob/62ff490619e7bd3554597c28c704081b4c15add5/src/main/java/io/github/hectorvent/floci/services/cloudtrail/CloudTrailService.java#L454-L490","documentation":"First branch of validateTrailName: CreateTrail (or anything that validates a new trail name) rejects a null or empty name with InvalidTrailNameException. It is the earliest name check, so an empty name always surfaces as this error rather than the length or character rules.","triggerScenarios":"CreateTrail with Name omitted, null, or an empty string — e.g. an unset template variable or a builder where name() was never called.","commonSituations":"Infrastructure templates with a missing name parameter; scripts deriving the trail name from an env var that is empty in CI; refactors that dropped the name assignment.","solutions":["Provide a non-empty Name (3-128 chars, letters/digits/._-, starting and ending alphanumeric).","Assert required parameters before the call so failures name the field locally.","Print the serialized request when debugging template-rendered calls."],"exampleFix":"// before\nclient.createTrail(b -> b.s3BucketName(bucket).build());\n\n// after\nclient.createTrail(b -> b.name(\"audit-trail\").s3BucketName(bucket).build());","handlingStrategy":"validation","validationCode":"if (name == null || name.isEmpty()) {\n    throw new IllegalArgumentException(\"Trail name is required\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    client.createTrail(req);\n} catch (InvalidTrailNameException e) {\n    // do not retry: fix the name per the message and call again\n}","preventionTips":["Validate all trail names with one shared helper before any CloudTrail call.","Fail fast on empty template variables used for names."],"tags":["aws","cloudtrail","validation","required-field","naming"],"backgroundTag":null,"analyzedSha":"62ff490619e7bd3554597c28c704081b4c15add5","analyzedAt":"2026-08-14T14:25:23.764Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}