{"record":{"id":"e977aea0de8851eb","repo":"kubernetes/kops","slug":"error-during-apply-w","errorCode":null,"errorMessage":"error during apply: %w","messagePattern":"error during apply: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/commands/toolbox_enroll.go","lineNumber":702,"sourceCode":"\n\tcloud, err := b.GetCloud(ctx)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// ApplyClusterCmd is used to get the assets.\n\t// We use DryRun and GetAssets to do this without applying any changes.\n\tapply := &cloudup.ApplyClusterCmd{\n\t\tCloud:      cloud,\n\t\tCluster:    cluster,\n\t\tClientset:  clientset,\n\t\tDryRun:     true,\n\t\tGetAssets:  true,\n\t\tTargetName: cloudup.TargetDryRun,\n\t}\n\tapplyResults, err := apply.Run(ctx)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error during apply: %w\", err)\n\t}\n\tb.AssetBuilder = applyResults.AssetBuilder\n\treturn b.AssetBuilder, nil\n}\n\nfunc (b *ConfigBuilder) GetWellKnownAddresses(ctx context.Context) (model.WellKnownAddresses, error) {\n\tif b.wellKnownAddresses != nil {\n\t\treturn *b.wellKnownAddresses, nil\n\t}\n\n\tcloud, err := b.GetCloud(ctx)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tfullCluster, err := b.GetFullCluster(ctx)\n\tif err != nil {\n\t\treturn nil, err","sourceCodeStart":684,"sourceCodeEnd":720,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/pkg/commands/toolbox_enroll.go#L684-L720","documentation":"GetAssetBuilder runs a full cloudup apply in DryRun mode (TargetDryRun, GetAssets=true) to build the asset builder. Any error returned by apply.Run is wrapped with 'error during apply: %w'. This surfaces all cluster-apply failures (validation, cloud API, templating) from the asset-building path.","triggerScenarios":"GetAssetBuilder (or GetBootstrapData which calls it) invoking apply.Run when the cluster spec fails validation, cloud credentials/API calls fail, or instance group/model rendering errors occur during dry-run apply.","commonSituations":"Invalid or outdated cluster spec (e.g. kubernetesVersion not supported); expired/insufficient cloud IAM credentials; unreachable cloud API (network/region mismatch); broken addons or hooks referencing missing files; feature-flag mismatch after kops upgrade.","solutions":["Read the wrapped cause (%w) — it names the actual apply failure; fix that underlying issue first.","Run `kops update cluster --dry-run` manually with the same flags to reproduce the apply error directly.","Validate the spec with `kops validate` / `kops replace -f` to catch schema/feature errors.","Refresh cloud credentials (AWS_PROFILE / GOOGLE_APPLICATION_CREDENTIALS / AZURE_AUTH) and retry.","Upgrade/align the kops binary version with the cluster's kopsVersionChannel."],"exampleFix":"// before\napplyResults, err := apply.Run(ctx)\nif err != nil { return nil, fmt.Errorf(\"error during apply: %w\", err) }\n// after\n// inspect the wrapped cause; e.g. fix the spec error reported by the inner apply error\napplyResults, err := apply.Run(ctx)\nif err != nil {\n\treturn nil, fmt.Errorf(\"error during apply: %w\", err) // fix cause reported by %w\n}","handlingStrategy":"try-catch","validationCode":"// Pre-flight: dry-run apply via the CLI to surface apply errors early\nif out, err := exec.Command(\"kops\", \"update\", \"cluster\", clusterName, \"--dry-run\").CombinedOutput(); err != nil {\n\treturn fmt.Errorf(\"apply pre-flight failed: %v: %s\", err, out)\n}","typeGuard":null,"tryCatchPattern":"var applyErr *ApplyError\nif errors.As(err, &applyErr) {\n\t// inspect applyErr cause: validation vs cloud API vs templating\n\treturn fmt.Errorf(\"apply failed: %w\", applyErr)\n}\nreturn err","preventionTips":["Run kops update cluster --dry-run before programmatic asset building","Keep cloud credentials fresh and scoped correctly","Pin the kops binary version to the cluster's supported version"],"tags":["kops","apply","dry-run","asset-builder"],"backgroundTag":"apply-failed","analyzedSha":"4c8573c808a73d578c5eadc86d410646ea0b0d73","analyzedAt":"2026-09-05T04:13:19.212Z","contentChangedAt":"2026-09-05T04:13:19.212Z","schemaVersion":2},"datasetVersion":"2026-09-12T12:17:11.808Z"}