{"record":{"id":"8f40d147caf7b50c","repo":"kubernetes/kops","slug":"mockawscloud-describeinstance-not-implemented","errorCode":null,"errorMessage":"MockAWSCloud DescribeInstance not implemented","messagePattern":"MockAWSCloud DescribeInstance not implemented","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/cloudup/awsup/mock_aws_cloud.go","lineNumber":193,"sourceCode":"\nfunc (c *MockAWSCloud) CreateELBV2Tags(ResourceArn string, tags map[string]string) error {\n\treturn createELBV2Tags(c, ResourceArn, tags)\n}\n\nfunc (c *MockAWSCloud) RemoveELBV2Tags(ResourceArn string, tags map[string]string) error {\n\treturn removeELBV2Tags(c, ResourceArn, tags)\n}\n\nfunc (c *MockAWSCloud) DescribeELBV2Tags(loadBalancerArns []string) (map[string][]elbv2types.Tag, error) {\n\treturn describeELBV2Tags(c, loadBalancerArns)\n}\n\nfunc (c *MockAWSCloud) FindELBV2NetworkInterfacesByName(vpcID, loadBalancerName string) ([]ec2types.NetworkInterface, error) {\n\treturn nil, nil\n}\n\nfunc (c *MockAWSCloud) DescribeInstance(instanceID string) (*ec2types.Instance, error) {\n\treturn nil, fmt.Errorf(\"MockAWSCloud DescribeInstance not implemented\")\n}\n\nfunc (c *MockAWSCloud) DescribeVPC(vpcID string) (*ec2types.Vpc, error) {\n\treturn describeVPC(c, vpcID)\n}\n\nfunc (c *MockAWSCloud) ResolveImage(name string) (*ec2types.Image, error) {\n\treturn resolveImage(context.TODO(), c.MockSSM, c.MockEC2, name)\n}\n\nfunc (c *MockAWSCloud) WithTags(tags map[string]string) AWSCloud {\n\tm := &MockAWSCloud{}\n\t*m = *c\n\tm.tags = tags\n\treturn m\n}\n\nfunc (c *MockAWSCloud) EC2() awsinterfaces.EC2API {","sourceCodeStart":175,"sourceCodeEnd":211,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/cloudup/awsup/mock_aws_cloud.go#L175-L211","documentation":"MockAWSCloud.DescribeInstance is an unimplemented stub on the test double; it always returns this error. It exists to satisfy the Cloud interface and indicates the code path under test reached EC2 instance description that the mock does not simulate.","triggerScenarios":"Any production code path invoked from a test calls DescribeInstance(instanceID) on a MockAWSCloud, e.g. validation or instance lookup logic running against mock clouds.","commonSituations":"Adding new code that calls cloud.DescribeInstance and running existing unit tests with mocks; tests exercising validation or fitask logic that now touches instance details; copy-pasting a test scenario from real-cloud to mock-cloud.","solutions":["Implement DescribeInstance in the test by extending the mock to return a canned ec2types.Instance for known instance IDs.","Restructure the test to avoid the code path requiring DescribeInstance, or use a small local stub that embeds MockAWSCloud and overrides DescribeInstance.","If this is newly needed production behavior, add mock support and a unit test covering it."],"exampleFix":"// before\nfunc (c *MockAWSCloud) DescribeInstance(instanceID string) (*ec2types.Instance, error) {\n\treturn nil, fmt.Errorf(\"MockAWSCloud DescribeInstance not implemented\")\n}\n// after\nfunc (c *MockAWSCloud) DescribeInstance(instanceID string) (*ec2types.Instance, error) {\n\tif i, ok := c.instances[instanceID]; ok {\n\t\treturn i, nil\n\t}\n\treturn nil, fmt.Errorf(\"instance %q not found\", instanceID)\n}","handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"inst, err := cloud.DescribeInstance(id)\nif err != nil && strings.Contains(err.Error(), \"not implemented\") {\n\t// test-double stub hit; skip or use fallback fixture data\n\tinst = fixtureInstance(id)\n}","preventionTips":["Embed MockAWSCloud and override DescribeInstance when tests need instance data","Keep mock coverage in sync when production code starts calling DescribeInstance","Note in test comments which Cloud interface methods the mock does not support"],"tags":["testing","mock","ec2","unimplemented"],"backgroundTag":"mock-not-implemented","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"}