{"record":{"id":"f6604ca077e858b4","repo":"kubernetes/kops","slug":"mockroute53-not-set","errorCode":null,"errorMessage":"MockRoute53 not set","messagePattern":"MockRoute53 not set","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/cloudup/awsup/mock_aws_cloud.go","lineNumber":114,"sourceCode":"\nfunc (c *MockAWSCloud) DetachInstance(i *cloudinstances.CloudInstance) error {\n\tctx := context.TODO()\n\n\treturn detachInstance(ctx, c, i)\n}\n\nfunc (c *MockAWSCloud) GetCloudGroups(cluster *kops.Cluster, instancegroups []*kops.InstanceGroup, warnUnmatched bool, nodes []v1.Node) (map[string]*cloudinstances.CloudInstanceGroup, error) {\n\tctx := context.TODO()\n\treturn getCloudGroups(ctx, c, cluster, instancegroups, warnUnmatched, nodes)\n}\n\nfunc (c *MockCloud) ProviderID() kops.CloudProviderID {\n\treturn kops.CloudProviderAWS\n}\n\nfunc (c *MockCloud) DNS() (dnsprovider.Interface, error) {\n\tif c.MockRoute53 == nil {\n\t\treturn nil, fmt.Errorf(\"MockRoute53 not set\")\n\t}\n\treturn dnsproviderroute53.New(c.MockRoute53), nil\n}\n\nfunc (c *MockAWSCloud) Region() string {\n\treturn c.region\n}\n\nfunc (c *MockAWSCloud) DescribeAvailabilityZones() ([]ec2types.AvailabilityZone, error) {\n\treturn c.zones, nil\n}\n\nfunc (c *MockAWSCloud) AddTags(name *string, tags map[string]string) {\n\tif name != nil {\n\t\ttags[\"Name\"] = *name\n\t}\n\tfor k, v := range c.tags {\n\t\ttags[k] = v","sourceCodeStart":96,"sourceCodeEnd":132,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/cloudup/awsup/mock_aws_cloud.go#L96-L132","documentation":"MockCloud.DNS() implements the awsup Cloud interface for testing. It requires the MockRoute53 field to be populated; if it is nil, the mock cannot construct a Route53 dnsprovider and returns this error. It signals incorrect test setup, not a runtime condition.","triggerScenarios":"A test creates a MockCloud/MockAWSCloud (e.g. via newMockAWSCloud or BuildMockAWSCloud) and calls DNS() without assigning MockRoute53, or explicitly sets it to nil.","commonSituations":"New unit tests reusing a partially initialized mock cloud; refactors that construct MockCloud structs directly instead of via the helper that wires MockRoute53; tests touching DNS functionality with mocks meant only for EC2/ELB.","solutions":["Initialize MockRoute53 with route53.New(route53.Options{Region: ...}) or use the existing mock constructor that wires it.","Use BuildMockAWSCloud/newMockAWSCloud helper rather than zero-value MockCloud structs.","If DNS is irrelevant to the test, avoid calling DNS() on the mock."],"exampleFix":"// before\nc := &MockCloud{}\ndns, err := c.DNS() // err: MockRoute53 not set\n// after\nc := &MockCloud{MockRoute53: route53.New(route53.Options{Region: \"us-east-1\"})}\ndns, err := c.DNS()","handlingStrategy":"validation","validationCode":"if c.MockRoute53 == nil {\n\tc.MockRoute53 = route53.New(route53.Options{Region: \"us-east-1\"})\n}","typeGuard":null,"tryCatchPattern":"dns, err := c.DNS()\nif err != nil {\n\tt.Fatalf(\"mock DNS not wired: %v\", err)\n}","preventionTips":["Always construct mocks via helper constructors (BuildMockAWSCloud) that wire all fields","Add a test-setup assertion that MockRoute53 is non-nil when DNS paths are exercised","Avoid zero-value MockCloud structs in new tests"],"tags":["testing","mock","route53","aws"],"backgroundTag":"mock-not-initialized","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"}