{"record":{"id":"3fe5cb6469c3b8d3","repo":"kubernetes/kops","slug":"error-reading-state-store-v","errorCode":null,"errorMessage":"error reading state store: %v","messagePattern":"error reading state store: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/client/simple/vfsclientset/cluster.go","lineNumber":165,"sourceCode":"\t\tc.SetGeneration(old.GetGeneration() + 1)\n\t}\n\n\tif err := r.writeConfig(ctx, c, r.basePath.Join(clusterName, registry.PathCluster), c, vfs.WriteOptionOnlyIfExists); err != nil {\n\t\tif os.IsNotExist(err) {\n\t\t\treturn nil, err\n\t\t}\n\t\treturn nil, fmt.Errorf(\"error writing Cluster: %v\", err)\n\t}\n\n\treturn c, nil\n}\n\n// List returns a slice containing all the cluster names\n// It skips directories that don't look like clusters\nfunc (r *ClusterVFS) listNames(ctx context.Context) ([]string, error) {\n\tpaths, err := r.basePath.ReadTree(ctx)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error reading state store: %v\", err)\n\t}\n\n\tvar keys []string\n\tfor _, p := range paths {\n\t\trelativePath, err := vfs.RelativePath(r.basePath, p)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tif !strings.HasSuffix(relativePath, \"/config\") {\n\t\t\tcontinue\n\t\t}\n\t\tkey := strings.TrimSuffix(relativePath, \"/config\")\n\t\tkeys = append(keys, key)\n\t}\n\treturn keys, nil\n}\n\nfunc (r *ClusterVFS) find(ctx context.Context, clusterName string) (*api.Cluster, error) {","sourceCodeStart":147,"sourceCodeEnd":183,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/pkg/client/simple/vfsclientset/cluster.go#L147-L183","documentation":"ClusterVFS.listNames enumerates clusters by reading the whole state-store tree via basePath.ReadTree. If reading the store fails (unreachable backend, bad credentials, missing store), the raw vfs error is wrapped in 'error reading state store'.","triggerScenarios":"Calling List (or anything calling listNames) when the state store path is wrong, the bucket does not exist, or the object store rejects the request.","commonSituations":"Typo in --state URL (e.g. s3://clusters vs s3://kops-clusters); region mismatch on the S3 bucket; credentials missing in CI; listing before any cluster was ever created and the prefix doesn't exist.","solutions":["Verify the state store URL is correct and the bucket exists (aws s3 ls s3://<bucket>)","Check cloud credentials/environment for the VFS backend","Create the bucket or set KOPS_STATE_STORE correctly before listing","If the store is legitimately empty, treat a not-found-style cause as an empty list"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"// verify state store before listing\nif os.Getenv(\"KOPS_STATE_STORE\") == \"\" && stateStoreURL == \"\" {\n\treturn fmt.Errorf(\"KOPS_STATE_STORE must be set before listing clusters\")\n}","typeGuard":null,"tryCatchPattern":"clusters, err := clusterVFS.List(ctx, metav1.ListOptions{})\nif err != nil && strings.Contains(err.Error(), \"error reading state store\") {\n\t// check if store is simply empty/uninitialized\n\tif exists, _ := r.basePath.Exists(); !exists {\n\t\treturn &api.ClusterList{}, nil\n\t}\n\treturn fmt.Errorf(\"cannot reach state store %s: %w\", basePath, err)\n}","preventionTips":["Verify the state store URL and bucket exist before kops commands","Export KOPS_STATE_STORE explicitly in CI environments","Check cloud credentials/region configuration","Initialize (create) the bucket before first use"],"tags":["go","vfs","storage","state-store"],"backgroundTag":"state-store-unreachable","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"}