{"record":{"id":"5ee9087abc262a97","repo":"floci-io/floci","slug":"validationerror","errorCode":"ValidationError","errorMessage":"Valid requests must contain either the InstanceID parameter or both the ImageId and InstanceType parameters.","messagePattern":"Valid requests must contain either the InstanceID parameter or both the ImageId and InstanceType parameters\\.","errorType":"exception","errorClass":"AwsException","httpStatus":400,"severity":"error","filePath":"src/main/java/io/github/hectorvent/floci/services/autoscaling/AutoScalingService.java","lineNumber":84,"sourceCode":"    private <V> Map<String, V> storageBacked(String fileName, TypeReference<Map<String, V>> typeReference)\n    {\n        return new StorageBackedMap<>(storageFactory.create(\"autoscaling\", fileName, typeReference));\n    }\n\n    // ── Launch Configurations ──────────────────────────────────────────────────\n\n    public LaunchConfiguration createLaunchConfiguration(String region, String name, String instanceId,\n                                                          String imageId, String instanceType, String keyName,\n                                                          List<String> securityGroups, String userData,\n                                                          String iamInstanceProfile,\n                                                          Boolean associatePublicIpAddress) {\n        String key = lcKey(region, name);\n        if (launchConfigs.containsKey(key)) {\n            throw new AwsException(\"AlreadyExists\",\n                    \"Launch configuration '\" + name + \"' already exists.\", 400);\n        }\n        if (isBlank(instanceId) && (isBlank(imageId) || isBlank(instanceType))) {\n            throw new AwsException(\"ValidationError\", INVALID_LAUNCH_CONFIGURATION_PARAMETERS_MESSAGE, 400);\n        }\n        if (notBlank(instanceId) && ec2Service != null) {\n            List<Instance> sourceInstances = ec2Service.describeInstances(region, List.of(instanceId), Map.of())\n                    .stream()\n                    .flatMap(reservation -> reservation.getInstances().stream())\n                    .collect(Collectors.toList());\n            if (!sourceInstances.isEmpty()) {\n                Instance source = sourceInstances.getFirst();\n                if (isBlank(imageId)) {\n                    imageId = source.getImageId();\n                }\n                if (isBlank(instanceType)) {\n                    instanceType = source.getInstanceType();\n                }\n                if (isBlank(keyName)) {\n                    keyName = source.getKeyName();\n                }\n                if ((securityGroups == null || securityGroups.isEmpty())","sourceCodeStart":66,"sourceCodeEnd":102,"githubUrl":"https://github.com/floci-io/floci/blob/62ff490619e7bd3554597c28c704081b4c15add5/src/main/java/io/github/hectorvent/floci/services/autoscaling/AutoScalingService.java#L66-L102","documentation":"Thrown by the Auto Scaling emulator's createLaunchConfiguration when neither InstanceId nor the pair (ImageId, InstanceType) is supplied. AWS requires a launch source: either clone a running EC2 instance by ID, or specify an AMI plus instance type. Missing both yields ValidationError / HTTP 400.","triggerScenarios":"createLaunchConfiguration called with only a name (e.g. aws autoscaling create-launch-configuration --launch-configuration-name web), or with ImageId but no InstanceType (or vice versa); templates where one parameter failed to interpolate.","commonSituations":"Terraform/CloudFormation templates with empty variable values; scripts where instance_type is conditionally empty; refactoring from instance-clone to image-based config and dropping one field.","solutions":["Provide both --image-id and --instance-type.","Or provide --instance-id to copy image/type/key/security groups from a running instance.","Validate your template variables render non-empty before applying.","If you pass InstanceId, ensure the EC2 emulator knows that instance."],"exampleFix":"# before\naws autoscaling create-launch-configuration --launch-configuration-name web\n\n# after\naws autoscaling create-launch-configuration \\\n  --launch-configuration-name web \\\n  --image-id ami-1234567890abcdef0 \\\n  --instance-type t3.micro","handlingStrategy":"validation","validationCode":"static void validateLaunchSource(String instanceId, String imageId, String instanceType) {\n    boolean hasInstance = instanceId != null && !instanceId.isBlank();\n    boolean hasPair = (imageId != null && !imageId.isBlank()) && (instanceType != null && !instanceType.isBlank());\n    if (!hasInstance && !hasPair)\n        throw new IllegalArgumentException(\n            \"Provide InstanceId, or both ImageId and InstanceType\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate the image/instance-type pair together — one without the other always fails.","Lint IaC templates for empty interpolated values in launch configuration blocks.","When cloning from InstanceId, confirm the instance exists in the EC2 emulator first."],"tags":["autoscaling","launch-configuration","validation","required-parameters","ec2"],"backgroundTag":null,"analyzedSha":"62ff490619e7bd3554597c28c704081b4c15add5","analyzedAt":"2026-08-14T14:25:23.764Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}