{"record":{"id":"7a5e4618c977f5b9","repo":"kubernetes/kops","slug":"failed-to-load-package-w","errorCode":null,"errorMessage":"failed to load package: %w","messagePattern":"failed to load package: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/wellknownoperators/operators.go","lineNumber":62,"sourceCode":"\tif !featureflag.UseAddonOperators.Enabled() {\n\t\treturn nil, objects, nil\n\t}\n\n\tvar packages []*Package\n\tvar keepObjects kubemanifest.ObjectList\n\n\tfor _, object := range objects {\n\t\tkeep := true\n\n\t\t// We may in future move ClusterPackage to the server-side,\n\t\t// however remapping it client-side allow us to use our existing manifest logic\n\t\t// including image remapping.\n\t\tif object.Kind() == \"ClusterPackage\" {\n\t\t\tu := object.ToUnstructured()\n\t\t\tif u.GroupVersionKind().Group == \"addons.x-k8s.io\" {\n\t\t\t\tpkg, err := b.loadClusterPackage(u)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, nil, fmt.Errorf(\"failed to load package: %w\", err)\n\t\t\t\t}\n\t\t\t\tpackages = append(packages, pkg)\n\t\t\t\tkeep = false\n\t\t\t}\n\t\t}\n\n\t\tif keep {\n\t\t\tkeepObjects = append(keepObjects, object)\n\t\t}\n\t}\n\treturn packages, keepObjects, nil\n}\n\nfunc (b *Builder) loadClusterPackage(u *unstructured.Unstructured) (*Package, error) {\n\toperatorKey := u.GetName()\n\tif operatorKey == \"\" {\n\t\treturn nil, fmt.Errorf(\"could not get name from ClusterPackage\")\n\t}","sourceCodeStart":44,"sourceCodeEnd":80,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/pkg/wellknownoperators/operators.go#L44-L80","documentation":"The wellknownoperators Builder.Build walks cluster objects and, for ClusterPackage objects in the addons.x-k8s.io group, loads the package from its manifest. If loadClusterPackage fails (unreadable/invalid package source), the error is wrapped with \"failed to load package\" and model building aborts. It indicates the ClusterPackage resource references something the builder cannot resolve or parse.","triggerScenarios":"b.loadClusterPackage(u) returns an error for a ClusterPackage object encountered during Build — bad spec.source, missing manifest, or nested load errors (e.g. could not get name/spec.version).","commonSituations":"A ClusterPackage added via kops create/apply with a wrong or unreachable source URL; manifest missing required metadata (name or spec.version empty — see errors 1789 and its sibling); addon manifests edited by hand; version skew between kops and the package spec schema.","solutions":["Inspect the ClusterPackage object (kops get clusterpackages / the addon manifest) and verify spec.source points to a reachable, valid package manifest","Ensure the package manifest has a valid name (metadata.name) and spec.version","Fix or remove the offending ClusterPackage from the cluster spec and re-run kops update cluster","Upgrade/align kops and the addon to compatible versions if the schema changed"],"exampleFix":"// before\nspec:\n  version: \"\"        # empty -> loadClusterPackage fails\n  source: https://example.com/missing-manifest.yaml\n// after\nspec:\n  version: \"1.0.0\"\n  source: https://example.com/valid-manifest.yaml","handlingStrategy":"validation","validationCode":"for _, obj := range objects {\n    if obj.Kind() == \"ClusterPackage\" && obj.GroupVersionKind().Group == \"addons.x-k8s.io\" {\n        if obj.GetName() == \"\" {\n            return fmt.Errorf(\"ClusterPackage without name in cluster spec\")\n        }\n        ver, found, _ := unstructured.NestedString(obj.Object, \"spec\", \"version\")\n        if !found || ver == \"\" {\n            return fmt.Errorf(\"ClusterPackage %s missing spec.version\", obj.GetName())\n        }\n    }\n}","typeGuard":null,"tryCatchPattern":"pkgs, keep, err := b.Build(ctx, objects, cluster, ...\nif err != nil {\n    if strings.Contains(err.Error(), \"failed to load package\") {\n        return fmt.Errorf(\"fix or remove the offending ClusterPackage: %w\", err)\n    }\n    return err\n}","preventionTips":["Validate addon manifests (name + spec.version + reachable source) before adding to the cluster","Keep addon/package sources in reachable, versioned locations","Align kops version with the package spec schema you use"],"tags":["go","kops","addons","clusterpackage","model-builder"],"backgroundTag":"cluster-package-load-failed","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"}