{"record":{"id":"7b331289641b424a","repo":"kubernetes/kops","slug":"found-multiple-instances-for-q","errorCode":null,"errorMessage":"found multiple Instances for %q","messagePattern":"found multiple Instances for %q","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/cloudup/awsup/aws_cloud.go","lineNumber":1653,"sourceCode":"\n\tresponse, err := c.EC2().DescribeInstances(ctx, request)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error listing Instances: %v\", err)\n\t}\n\tif response == nil || len(response.Reservations) == 0 {\n\t\treturn nil, nil\n\t}\n\tif len(response.Reservations) != 1 {\n\t\tklog.Fatalf(\"found multiple Reservations for %q\", instanceID)\n\t}\n\n\treservation := response.Reservations[0]\n\tif len(reservation.Instances) == 0 {\n\t\treturn nil, nil\n\t}\n\n\tif len(reservation.Instances) != 1 {\n\t\treturn nil, fmt.Errorf(\"found multiple Instances for %q\", instanceID)\n\t}\n\n\tinstance := reservation.Instances[0]\n\treturn &instance, nil\n}\n\n// DescribeVPC is a helper that queries for the specified vpc by id\nfunc (c *awsCloudImplementation) DescribeVPC(vpcID string) (*ec2types.Vpc, error) {\n\treturn describeVPC(c, vpcID)\n}\n\nfunc describeVPC(c AWSCloud, vpcID string) (*ec2types.Vpc, error) {\n\tklog.V(2).Infof(\"Calling DescribeVPC for VPC %q\", vpcID)\n\tctx := context.TODO()\n\trequest := &ec2.DescribeVpcsInput{\n\t\tVpcIds: []string{vpcID},\n\t}\n","sourceCodeStart":1635,"sourceCodeEnd":1671,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/cloudup/awsup/aws_cloud.go#L1635-L1671","documentation":"kOps expects DescribeInstances for a single instance ID to return exactly one instance. If the reservation contains more than one instance, this error is returned because the API contract (one instance per ID lookup) is violated.","triggerScenarios":"Extremely rare AWS-side anomaly or a kOps bug where the response for a single-instance describe contains multiple instances in reservation.Instances.","commonSituations":"Corrupted API responses, client/deserializer issues with a particular AWS SDK version, or passing a non-specific query path that returned a reservation with multiple instances.","solutions":["Retry the operation; a transient anomaly usually resolves.","Upgrade kops and the AWS SDK to current versions to pick up deserialization fixes.","Run `aws ec2 describe-instances --instance-ids <id>` to check what AWS actually returns.","If reproducible, file a kOps issue with the instance ID and region."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"// Sanity-check via direct AWS call before trusting kops' single-instance invariant\nout, _ := ec2Client.DescribeInstances(ctx, &ec2.DescribeInstancesInput{InstanceIds: []string{instanceID}})\n// inspect len(out.Reservations[0].Instances) yourself","typeGuard":null,"tryCatchPattern":"inst, err := c.DescribeInstance(instanceID)\nif err != nil && strings.HasPrefix(err.Error(), \"found multiple Instances\") {\n    // log and fall back to full describe + manual selection\n    return nil, fmt.Errorf(\"ambiguous describe response for %s: %w\", instanceID, err)\n}","preventionTips":["Keep kops and AWS SDK versions current","Verify raw AWS responses with the CLI when invariants break","Retry once before failing hard on anomalous responses","Report reproducible multi-instance responses upstream"],"tags":["aws","ec2","instances","invariant-violation"],"backgroundTag":"api-response-invariant-violation","analyzedSha":"4c8573c808a73d578c5eadc86d410646ea0b0d73","analyzedAt":"2026-09-05T04:13:19.212Z","contentChangedAt":"2026-09-05T04:13:19.212Z","schemaVersion":2},"datasetVersion":"2026-09-12T07:17:12.445Z"}