{"record":{"id":"5e589868467292b9","repo":"FiloSottile/age","slug":"s-stanza-has-d-arguments-want-d","errorCode":null,"errorMessage":"%s stanza has %d arguments, want %d","messagePattern":"(.+?) stanza has (.+?) arguments, want (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"plugin/plugin.go","lineNumber":590,"sourceCode":"\treturn s.Args[0] == \"yes\", nil\n}\n\n// fatalInteractf prints the error to stderr and sets the broken flag, so the\n// Wrap/Unwrap caller can exit with an error.\nfunc (p *Plugin) fatalInteractf(format string, args ...any) error {\n\tp.broken = true\n\tfmt.Fprintf(p.stderr, format, args...)\n\treturn fmt.Errorf(format, args...)\n}\n\nfunc (p *Plugin) fatalf(format string, args ...any) int {\n\tfmt.Fprintf(p.stderr, format, args...)\n\treturn 1\n}\n\nfunc expectStanzaWithNoBody(s *format.Stanza, wantArgs int) error {\n\tif len(s.Args) != wantArgs {\n\t\treturn fmt.Errorf(\"%s stanza has %d arguments, want %d\", s.Type, len(s.Args), wantArgs)\n\t}\n\tif len(s.Body) != 0 {\n\t\treturn fmt.Errorf(\"%s stanza has %d bytes of body, want 0\", s.Type, len(s.Body))\n\t}\n\treturn nil\n}\n\nfunc expectStanzaWithBody(s *format.Stanza, wantArgs int) error {\n\tif err := expectStanzaWithAnyBody(s, wantArgs); err != nil {\n\t\treturn err\n\t}\n\tif len(s.Body) == 0 {\n\t\treturn fmt.Errorf(\"%s stanza has 0 bytes of body, want >0\", s.Type)\n\t}\n\treturn nil\n}\n\nfunc expectStanzaWithAnyBody(s *format.Stanza, wantArgs int) error {","sourceCodeStart":572,"sourceCodeEnd":608,"githubUrl":"https://github.com/FiloSottile/age/blob/b74dce4cdbe35b5e5f66c06d9612b72f89028758/plugin/plugin.go#L572-L608","documentation":"This error comes from the age plugin protocol client helper expectStanzaWithNoBody. It fires when a protocol stanza expected to carry exactly `wantArgs` arguments and no body instead carries a different number of space-separated arguments on its first line. The plugin protocol is line/stanza based, so argument counts are strict; a mismatch means the other side emitted a malformed stanza. It is a protocol-conformance failure, not a crypto failure.","triggerScenarios":"RecipientV1 or IdentityV1 received a reply stanza (ok, fail, unsupported, or a recipient/identity-specific stanza) whose Args slice length differs from the expected count; e.g. an 'ok' stanza with trailing arguments, or a 'unsupported' stanza where the plugin added an unexpected extra argument.","commonSituations":"Using a plugin binary that speaks a different (older/newer) plugin protocol revision than this client expects; a buggy third-party age plugin that appends extra fields; a hand-rolled test harness emitting stanzas with wrong argument counts; whitespace/quoting bugs when the plugin builds its reply line.","solutions":["Check the plugin binary version and upgrade or downgrade it so it matches the plugin protocol revision this library implements","Print the raw stanza (s.Type and s.Args) at the failure point to see which argument was added or dropped","If you wrote the plugin, fix the code that formats the reply so it emits exactly the required arguments with no extras","If you control the harness, regenerate expected stanzas from the protocol spec"],"exampleFix":"// before (plugin side)\nfmt.Printf(\"-> unsupported\\n\\n\") // missing required argument\n\n// after\nfmt.Printf(\"-> unsupported %s\\n\\n\", errReason)","handlingStrategy":"validation","validationCode":"if len(stanza.Args) != wantArgs {\n    return fmt.Errorf(\"plugin sent %s with %d args, want %d\", stanza.Type, len(stanza.Args), wantArgs)\n}","typeGuard":"func isWellFormedStanza(s *format.Stanza, wantArgs int) bool {\n    return s != nil && len(s.Args) == wantArgs\n}","tryCatchPattern":null,"preventionTips":["Pin the plugin binary version alongside the age library version","Log raw stanzas (type + args) before validation in tests","Keep plugin stdout strictly protocol-only"],"tags":["age","plugin-protocol","stanza","argument-count"],"backgroundTag":"plugin-stanza-argument-count-mismatch","analyzedSha":"b74dce4cdbe35b5e5f66c06d9612b72f89028758","analyzedAt":"2026-08-31T23:59:31.627Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}