{"record":{"id":"6da82d15e63cc273","repo":"getsops/sops","slug":"failed-to-read-q-w","errorCode":null,"errorMessage":"failed to read %q: %w","messagePattern":"failed to read %q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"age/ssh_parse.go","lineNumber":36,"sourceCode":"\t\"filippo.io/age\"\n\t\"filippo.io/age/agessh\"\n\t\"golang.org/x/crypto/ssh\"\n)\n\n// readPublicKeyFile attempts to read a public key based on the given private\n// key path. It assumes the public key is in the same directory, with the same\n// name, but with a \".pub\" extension. If the public key cannot be read, an\n// error is returned.\nfunc readPublicKeyFile(privateKeyPath string) (ssh.PublicKey, error) {\n\tpublicKeyPath := privateKeyPath + \".pub\"\n\tf, err := os.Open(publicKeyPath)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to obtain public %q key for %q SSH key: %w\", publicKeyPath, privateKeyPath, err)\n\t}\n\tdefer f.Close()\n\tcontents, err := io.ReadAll(f)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to read %q: %w\", publicKeyPath, err)\n\t}\n\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)","sourceCodeStart":18,"sourceCodeEnd":54,"githubUrl":"https://github.com/getsops/sops/blob/13442bb98183887d7a9ac09ec8ab0564673a59d8/age/ssh_parse.go#L18-L54","documentation":"Error \"failed to read %q: %w\" thrown in getsops/sops.","triggerScenarios":"Thrown at age/ssh_parse.go:36 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"}