{"record":{"id":"64a9131470078027","repo":"kubernetes/kops","slug":"error-parsing-v","errorCode":null,"errorMessage":"error parsing: %v","messagePattern":"error parsing: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"pkg/commands/helpers/kubectl_auth.go","lineNumber":214,"sourceCode":"\t\tsanitizedName = sanitizedName[:32]\n\t}\n\treturn filepath.Join(homedir.HomeDir(), \".kube\", \"cache\", \"kops-authentication\", sanitizedName+\"_\"+hash)\n}\n\nfunc loadCachedExecCredential(cacheFilePath string) (*ExecCredential, error) {\n\tb, err := os.ReadFile(cacheFilePath)\n\tif err != nil {\n\t\tif os.IsNotExist(err) {\n\t\t\t// expected - a cache miss\n\t\t\treturn nil, nil\n\t\t} else {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\texecCredential := &ExecCredential{}\n\tif err := json.Unmarshal(b, execCredential); err != nil {\n\t\treturn nil, fmt.Errorf(\"error parsing: %v\", err)\n\t}\n\n\tif execCredential.Status.ExpirationTimestamp.Before(time.Now()) {\n\t\treturn nil, nil\n\t}\n\n\tif execCredential.Status.ClientCertificateData == \"\" || execCredential.Status.ClientKeyData == \"\" {\n\t\treturn nil, fmt.Errorf(\"no credentials in cached file\")\n\t}\n\n\treturn execCredential, nil\n}\n\nfunc buildCredentials(ctx context.Context, f *util.Factory, options *HelperKubectlAuthOptions) (*ExecCredentialStatus, error) {\n\tclientset, err := f.KopsClient()\n\tif err != nil {\n\t\treturn nil, err\n\t}","sourceCodeStart":196,"sourceCodeEnd":232,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/pkg/commands/helpers/kubectl_auth.go#L196-L232","documentation":"loadCachedExecCredential reads the on-disk credential cache and unmarshals it into ExecCredential. If the file exists but is not valid JSON matching the struct, it returns this 'error parsing' wrapper. The caller (RunKubectlAuthHelper) treats any load error as a cache miss and re-issues credentials, so this is usually benign — it just forces a new certificate issue.","triggerScenarios":"The file at ~/.kube/cache/kops-authentication/<name>_<hash> exists but contains garbage: truncated writes, hand-edited content, another tool overwriting it, or filesystem corruption.","commonSituations":"Manual inspection/editing of the cache file; disk-full during a previous write leaving a partial file; copying cache files between machines or state stores.","solutions":["Delete the corrupt cache file under ~/.kube/cache/kops-authentication/ and re-run; a fresh credential will be issued.","No action strictly needed — the helper logs via klog.Infof and falls back to issuing new credentials.","Avoid hand-editing cache files; the cache is derived from the kOps state store."],"exampleFix":"// before\ncat ~/.kube/cache/kops-authentication/mycluster_ab12cd  # corrupt\n// after\nrm ~/.kube/cache/kops-authentication/mycluster_ab12cd","handlingStrategy":"fallback","validationCode":"b, err := os.ReadFile(path)\nif err == nil && !json.Valid(b) {\n    os.Remove(path) // drop corrupt cache before invoking the helper\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Let the helper re-issue credentials on parse errors — it already falls back automatically.","Don't manually edit or truncate cache files.","Watch klog for 'cached credential ... was not valid' and delete the named file."],"tags":["json","cache","parsing"],"backgroundTag":"invalid-json","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"}