{"record":{"id":"38ecf9cf0ff62e13","repo":"floci-io/floci","slug":"trailnotfoundexception","errorCode":"TrailNotFoundException","errorMessage":"Unknown trail: {}","messagePattern":"Unknown trail: (.+?)","errorType":"exception","errorClass":"AwsException","httpStatus":400,"severity":"error","filePath":"src/main/java/io/github/hectorvent/floci/services/cloudtrail/CloudTrailService.java","lineNumber":464,"sourceCode":"            for (String k : store.keys()) {\n                CloudTrailEntry entry = store.get(k).orElse(null);\n                if (entry == null) continue;\n                if (nameOrArn.equals(entry.trail().trailArn())) {\n                    return entry.trail();\n                }\n            }\n            return null;\n        }\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))) {","sourceCodeStart":446,"sourceCodeEnd":482,"githubUrl":"https://github.com/floci-io/floci/blob/62ff490619e7bd3554597c28c704081b4c15add5/src/main/java/io/github/hectorvent/floci/services/cloudtrail/CloudTrailService.java#L446-L482","documentation":"Thrown by findTrailOrThrow when no trail matches the given name or ARN. Lookup is region-scoped for names (regionKey) and ARN-based otherwise; a miss raises TrailNotFoundException. Note HTTP status is 400 here, whereas the AWS SDK maps TrailNotFoundException to 404-like semantics — SDK exception typing still works by error code.","triggerScenarios":"DeleteTrail/UpdateTrail/StartLogging/StopLogging/GetTrailStatus/PutEventSelectors with a trail name that does not exist in the current region, or a typo'd/malformed ARN; also using a name scoped to a different region (names resolve only in their own region).","commonSituations":"Multi-region setups where the trail exists in us-east-1 but the client is pointed at another region; stale config after a trail was deleted; string interpolation that leaves a placeholder in the name.","solutions":["DescribeTrails to confirm the trail exists and note its HomeRegion.","Verify the client is configured for the region where the trail was created.","Copy the exact name/ARN from the create response or DescribeTrails output rather than reconstructing it."],"exampleFix":"// before\nclient.deleteTrail(b -> b.name(\"audit-trail\")); // wrong region client\n\n// after\nclient = CloudTrailClient.builder().region(Region.US_EAST_1).build();\nclient.deleteTrail(b -> b.name(\"audit-trail\"));","handlingStrategy":"try-catch","validationCode":"boolean found = client.describeTrails().trailList().stream()\n    .anyMatch(t -> nameOrArn.equals(t.name()) || nameOrArn.equals(t.trailARN()));\nif (!found) throw new IllegalStateException(\"No trail '\" + nameOrArn + \"' in \" + region);","typeGuard":null,"tryCatchPattern":"try {\n    client.deleteTrail(b -> b.name(name));\n} catch (TrailNotFoundException e) {\n    // already deleted (possibly in another region): treat as idempotent success\n}","preventionTips":["Confirm the trail's HomeRegion via DescribeTrails and point the client there.","Store trail ARNs from creation output and use ARNs for subsequent operations."],"tags":["aws","cloudtrail","not-found","region"],"backgroundTag":null,"analyzedSha":"62ff490619e7bd3554597c28c704081b4c15add5","analyzedAt":"2026-08-14T14:25:23.764Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}