{"record":{"id":"1d7d21c94c3bcd1e","repo":"getsops/sops","slug":"failed-to-read-file-w","errorCode":null,"errorMessage":"failed to read file: %w","messagePattern":"failed to read file: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"age/ssh_parse.go","lineNumber":56,"sourceCode":"\tpubKey, _, _, _, err := ssh.ParseAuthorizedKey(contents)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to parse %q: %w\", publicKeyPath, err)\n\t}\n\treturn pubKey, nil\n}\n\n// parseSSHIdentityFromPrivateKeyFile returns an age.Identity from the given\n// private key file. If the private key file is encrypted, it will configure\n// the identity to prompt for a passphrase.\nfunc parseSSHIdentityFromPrivateKeyFile(keyPath string) (age.Identity, error) {\n\tkeyFile, err := os.Open(keyPath)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to open file: %w\", err)\n\t}\n\tdefer keyFile.Close()\n\tcontents, err := io.ReadAll(keyFile)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to read file: %w\", err)\n\t}\n\tid, err := agessh.ParseIdentity(contents)\n\tif sshErr, ok := err.(*ssh.PassphraseMissingError); ok {\n\t\tpubKey := sshErr.PublicKey\n\t\tif pubKey == nil {\n\t\t\tpubKey, err = readPublicKeyFile(keyPath)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t}\n\t\tpassphrasePrompt := func() ([]byte, error) {\n\t\t\tpass, err := pluginTerminalUI.RequestValue(\"\", fmt.Sprintf(\"Enter passphrase for %q:\", keyPath), true)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"could not read passphrase for %q: %v\", keyPath, err)\n\t\t\t}\n\t\t\treturn []byte(pass), nil\n\t\t}\n\t\ti, err := agessh.NewEncryptedSSHIdentity(pubKey, contents, passphrasePrompt)","sourceCodeStart":38,"sourceCodeEnd":74,"githubUrl":"https://github.com/getsops/sops/blob/13442bb98183887d7a9ac09ec8ab0564673a59d8/age/ssh_parse.go#L38-L74","documentation":"Error \"failed to read file: %w\" thrown in getsops/sops.","triggerScenarios":"Thrown at age/ssh_parse.go:56 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"13442bb98183887d7a9ac09ec8ab0564673a59d8","analyzedAt":"2026-09-01T03:53:00.447Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}