floci-io/floci · error · AwsException

InvalidAction

InvalidAction

Error message

Could not find operation {}

What it means

Thrown by Floci's CloudTrail JSON handler when the X-Amz-Target action is not one of the ten implemented CloudTrail operations (CreateTrail, DescribeTrails, DeleteTrail, UpdateTrail, PutEventSelectors, GetEventSelectors, StartLogging, StopLogging, GetTrailStatus, LookupEvents). The switch default raises InvalidAction with the unmatched action name, mirroring AWS's response to an unknown action.

Source

Thrown at src/main/java/io/github/hectorvent/floci/services/cloudtrail/CloudTrailJsonHandler.java:41

    @Inject
    public CloudTrailJsonHandler(CloudTrailService service, ObjectMapper mapper) {
        this.service = service;
        this.mapper = mapper;
    }

    public Response handle(String action, JsonNode request, String region) throws Exception {
        return switch (action) {
            case "CreateTrail" -> createTrail(request, region);
            case "DescribeTrails" -> describeTrails(request, region);
            case "DeleteTrail" -> deleteTrail(request, region);
            case "UpdateTrail" -> updateTrail(request, region);
            case "PutEventSelectors" -> putEventSelectors(request, region);
            case "GetEventSelectors" -> getEventSelectors(request, region);
            case "StartLogging" -> startLogging(request, region);
            case "StopLogging" -> stopLogging(request, region);
            case "GetTrailStatus" -> getTrailStatus(request, region);
            case "LookupEvents" -> lookupEvents(request, region);
            default -> throw new AwsException(
                    "InvalidAction", "Could not find operation " + action, 400);
        };
    }

    private Response createTrail(JsonNode req, String region) {
        String name = req.path("Name").asText(null);
        String s3BucketName = req.path("S3BucketName").asText(null);
        String s3KeyPrefix = req.has("S3KeyPrefix") ? req.path("S3KeyPrefix").asText(null) : null;
        String snsTopicArn = req.has("SnsTopicARN") ? req.path("SnsTopicARN").asText(null)
                : req.has("SnsTopicName") ? req.path("SnsTopicName").asText(null) : null;
        boolean includeGlobal = req.path("IncludeGlobalServiceEvents").asBoolean(true);
        boolean isMultiRegion = req.path("IsMultiRegionTrail").asBoolean(false);
        boolean enableLogFileValidation = req.path("EnableLogFileValidation").asBoolean(false);
        boolean isOrganizationTrail = req.path("IsOrganizationTrail").asBoolean(false);

        Trail trail = service.createTrail(region, name, s3BucketName, s3KeyPrefix, snsTopicArn,
                includeGlobal, isMultiRegion, enableLogFileValidation, isOrganizationTrail);

View on GitHub (pinned to 62ff490619)

Solutions

  1. Check the supported-action list above and restrict the test/tooling to those operations against Floci.
  2. If a raw request, verify the X-Amz-Target header format: AwsCloudTrailVersion20131101.<Action>.
  3. For genuinely missing operations, file/track an emulator coverage request or implement the handler case locally.

Example fix

// before
cloudtrailClient.listPublicKeys(); // not implemented by emulator

// after
// use only implemented actions, e.g.
cloudtrailClient.describeTrails();
Defensive patterns

Strategy: validation

Validate before calling

Set<String> SUPPORTED = Set.of("CreateTrail","DescribeTrails","DeleteTrail","UpdateTrail",
    "PutEventSelectors","GetEventSelectors","StartLogging","StopLogging",
    "GetTrailStatus","LookupEvents");
if (!SUPPORTED.contains(action)) {
    throw new UnsupportedOperationException("CloudTrail action not supported by emulator: " + action);
}

Try / catch

try {
    dispatch(action, request);
} catch (InvalidActionException e) {
    // unsupported by emulator: skip or run only against real AWS
}

Prevention

When it happens

Trigger: Calling a CloudTrail operation Floci does not implement yet (e.g. ListPublicKeys, PutInsightSelectors, RestoreEventDataStore) via SDK/CLI or raw X-Amz-Target header; a typo in a hand-crafted target header; an SDK newer than the emulator's coverage.

Common situations: Porting a test suite from real AWS to Floci that exercises lesser-used CloudTrail APIs; version skew between the AWS SDK in use and the emulator build; hand-rolled HTTP clients with copy-paste target strings.

Related errors


AI-assisted analysis of floci-io/floci@62ff490619 (2026-08-14). Data as JSON: /api/errors/7ee4256c7dec0f38. Report an issue: GitHub.