{"record":{"id":"b05954e02e1da019","repo":"kubernetes/kops","slug":"error-parsing-cluster-q-v","errorCode":null,"errorMessage":"error parsing Cluster %q: %v","messagePattern":"error parsing Cluster %q: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/kops/get_cluster.go","lineNumber":297,"sourceCode":"\treturn nil\n}\n\nfunc fullClusterSpecs(ctx context.Context, vfsContext *vfs.VFSContext, clusters []*kopsapi.Cluster) ([]*kopsapi.Cluster, error) {\n\tvar fullSpecs []*kopsapi.Cluster\n\tfor _, cluster := range clusters {\n\t\tconfigBase, err := registry.ConfigBase(vfsContext, cluster)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"error reading full cluster spec for %q: %v\", cluster.ObjectMeta.Name, err)\n\t\t}\n\t\tconfigPath := configBase.Join(registry.PathClusterCompleted)\n\t\tb, err := configPath.ReadFile(ctx)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"error loading Cluster %q: %v\", configPath, err)\n\t\t}\n\n\t\to, _, err := kopscodecs.Decode(b, nil)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"error parsing Cluster %q: %v\", configPath, err)\n\t\t}\n\t\tif fullSpec, ok := o.(*kopsapi.Cluster); ok {\n\t\t\tfullSpecs = append(fullSpecs, fullSpec)\n\t\t} else {\n\t\t\treturn nil, fmt.Errorf(\"unexpected object type for Cluster %q: %T\", configPath, o)\n\t\t}\n\t}\n\treturn fullSpecs, nil\n}\n","sourceCodeStart":279,"sourceCodeEnd":307,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/cmd/kops/get_cluster.go#L279-L307","documentation":"fullClusterSpecs decodes the raw bytes of cluster-completed.spec with kopscodecs.Decode; if the payload is corrupt, in an unsupported version, or not valid serialized API data, the error is wrapped as 'error parsing Cluster %q: %v'. This is a deserialization failure, distinct from a read failure.","triggerScenarios":"`kops get cluster X --full` where the stored spec was hand-edited, truncated by a failed upload, created by an incompatible kops version (codec/scheme mismatch), or otherwise not a decodable kops API object.","commonSituations":"Manual edits to state-store YAML introducing syntax errors; kops major-version skew between the binary and the cluster spec (e.g. old spec with retired API version); partially uploaded objects.","solutions":["Use a kops binary version compatible with the cluster's kubernetesVersion/spec (check `kops version` vs the cluster's creation version).","Inspect the raw object (`aws s3 cp ... -` or gsutil cat) for corruption or manual edits; restore it from backup or re-run `kops update cluster` to regenerate.","Compare the apiVersion/kind in the stored spec against supported kops API versions for your binary.","Never hand-edit state-store objects; edit via `kops edit cluster` instead."],"exampleFix":"// before\n# spec stored with unsupported apiVersion after kops downgrade\nkops get cluster X --full   # kops 1.19 binary vs cluster updated by 1.25\n// after\n# upgrade the kops binary to match the cluster\nbrew upgrade kops && kops get cluster X --full","handlingStrategy":"validation","validationCode":"# sanity: kops binary version should match cluster creation version\nkv=$(kops version | grep -o '[0-9]*\\.[0-9]*' | head -1)\ncv=$(kops get cluster \"$CLUSTER\" -o json | jq -r '.spec.kubernetesVersion')\necho \"kops=$kv k8s=$cv\"  # mismatched major versions can break decoding","typeGuard":"null","tryCatchPattern":"if ! kops get cluster \"$CLUSTER\" --full 2>err.txt; then\n  grep -q 'error parsing Cluster' err.txt && \\\n    { echo \"spec corrupt or version mismatch; verify kops version vs cluster spec\"; aws s3 cp \".../cluster-completed.spec\" - ; }\nfi","preventionTips":["Never hand-edit state-store objects; use `kops edit cluster` + `kops update cluster`.","Keep the kops binary version aligned with the cluster's spec generation.","Back up cluster-completed.spec before kops upgrades that rewrite API versions."],"tags":["serialization","cluster-spec","codec"],"backgroundTag":"manifest-decode-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"}