plugin: fix returning in-protocol errors from plugins

Fixes Foxboron/age-plugin-tpm#31
This commit is contained in:
Filippo Valsorda
2025-12-23 13:11:49 +01:00
parent 9795b63263
commit f3b008d1b8
2 changed files with 63 additions and 1 deletions
+1 -1
View File
@@ -654,7 +654,7 @@ func expectUnsupported(sr *format.StanzaReader) error {
func (p *Plugin) writeError(args []string, err error) error {
s := &format.Stanza{Type: "error", Args: args}
s.Body = []byte(err.Error())
if err := s.Marshal(p.stderr); err != nil {
if err := s.Marshal(p.stdout); err != nil {
return fmt.Errorf("failed to write error stanza: %v", err)
}
if err := expectOk(p.sr); err != nil {