FiloSottile/age · error

%s stanza has 0 bytes of body, want >0

Error message

%s stanza has 0 bytes of body, want >0

What it means

expectStanzaWithBody enforces that a stanza which must carry payload data (e.g. the 'msg' body of a DisplayMessage or the prompt data of a Confirm/RequestValue reply path) actually has a non-empty body. A zero-length body means the plugin sent the stanza line but omitted the required data. The client cannot proceed without that payload.

Source

Thrown at plugin/plugin.go:603

	return 1
}

func expectStanzaWithNoBody(s *format.Stanza, wantArgs int) error {
	if len(s.Args) != wantArgs {
		return fmt.Errorf("%s stanza has %d arguments, want %d", s.Type, len(s.Args), wantArgs)
	}
	if len(s.Body) != 0 {
		return fmt.Errorf("%s stanza has %d bytes of body, want 0", s.Type, len(s.Body))
	}
	return nil
}

func expectStanzaWithBody(s *format.Stanza, wantArgs int) error {
	if err := expectStanzaWithAnyBody(s, wantArgs); err != nil {
		return err
	}
	if len(s.Body) == 0 {
		return fmt.Errorf("%s stanza has 0 bytes of body, want >0", s.Type)
	}
	return nil
}

func expectStanzaWithAnyBody(s *format.Stanza, wantArgs int) error {
	if len(s.Args) != wantArgs {
		return fmt.Errorf("%s stanza has %d arguments, want %d", s.Type, len(s.Args), wantArgs)
	}
	return nil
}

func (p *Plugin) recipientError(idx int, err error) int {
	if err := p.writeError([]string{"recipient", fmt.Sprint(idx)}, err); err != nil {
		return p.fatalf("%v", err)
	}
	return 3
}

View on GitHub (pinned to b74dce4cdb)

Solutions

  1. Check the plugin's stderr/logs for an internal failure that caused it to skip writing the body
  2. Upgrade the plugin to a version matching this client's protocol expectations
  3. Inspect the stanza type and args to confirm which payload was expected and why the plugin omitted it
  4. If you wrote the plugin, ensure it writes body bytes followed by a blank line before terminating the stanza

Example fix

// before (plugin side)
fmt.Printf("-> msg\n\n") // empty body

// after
fmt.Printf("-> msg\n%s\n\n", messageText)
Defensive patterns

Strategy: validation

Validate before calling

if len(stanza.Body) == 0 {
    return fmt.Errorf("%s requires a non-empty body", stanza.Type)
}

Type guard

func hasBody(s *format.Stanza) bool {
    return s != nil && len(s.Body) > 0
}

Prevention

When it happens

Trigger: RecipientV1 read a stanza (via expectStanzaWithBody) whose argument count was correct but whose Body was empty — for instance a data-carrying reply stanza terminated immediately with a blank line.

Common situations: A plugin that hits an internal error and emits the stanza skeleton without the data; truncation of the plugin's stdout (short read, closed pipe); protocol mismatch where an older plugin omits a body this client requires.

Related errors


AI-assisted analysis of FiloSottile/age@b74dce4cdb (2026-08-31). Data as JSON: /api/errors/69bc05044a1729cf. Report an issue: GitHub.