{"record":{"id":"098b65d16457f354","repo":"getsops/sops","slug":"could-not-establish-connection-with-gpg-agent-s","errorCode":null,"errorMessage":"could not establish connection with gpg-agent: %s","messagePattern":"could not establish connection with gpg-agent: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pgp/keysource.go","lineNumber":567,"sourceCode":"\t\t}\n\t\tcallCounter++\n\n\t\tconn, err := gpgagent.NewConn()\n\t\tif err == gpgagent.ErrNoAgent {\n\t\t\tlog.Infof(\"gpg-agent not found, continuing with manual passphrase \" +\n\t\t\t\t\"input...\")\n\t\t\tfmt.Print(\"Enter PGP key passphrase: \")\n\t\t\tpass, err := term.ReadPassword(int(os.Stdin.Fd()))\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\tfor _, k := range keys {\n\t\t\t\tk.PrivateKey.Decrypt(pass)\n\t\t\t}\n\t\t\treturn pass, err\n\t\t}\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"could not establish connection with gpg-agent: %s\", err)\n\t\t}\n\t\tdefer func(conn *gpgagent.Conn) {\n\t\t\tif err := conn.Close(); err != nil {\n\t\t\t\tlog.Errorf(\"failed to close connection with gpg-agent: %s\", err)\n\t\t\t}\n\t\t}(conn)\n\n\t\tfor _, k := range keys {\n\t\t\treq := gpgagent.PassphraseRequest{\n\t\t\t\tCacheKey: k.PublicKey.KeyIdShortString(),\n\t\t\t\tPrompt:   \"Passphrase\",\n\t\t\t\tDesc:     fmt.Sprintf(\"Unlock key %s to decrypt sops's key\", k.PublicKey.KeyIdShortString()),\n\t\t\t}\n\t\t\tpass, err := conn.GetPassphrase(&req)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"gpg-agent passphrase request errored: %s\", err)\n\t\t\t}\n\t\t\tk.PrivateKey.Decrypt([]byte(pass))","sourceCodeStart":549,"sourceCodeEnd":585,"githubUrl":"https://github.com/getsops/sops/blob/13442bb98183887d7a9ac09ec8ab0564673a59d8/pgp/keysource.go#L549-L585","documentation":"Error \"could not establish connection with gpg-agent: %s\" thrown in getsops/sops.","triggerScenarios":"Thrown at pgp/keysource.go:567 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"}