{"record":{"id":"4910903a8b1b66cb","repo":"FiloSottile/age","slug":"malformed-confirm-stanza-unexpected-number-of-arg","errorCode":null,"errorMessage":"malformed confirm stanza: unexpected number of arguments","messagePattern":"malformed confirm stanza: unexpected number of arguments","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"plugin/client.go","lineNumber":360,"sourceCode":"\t\tif c.DisplayMessage == nil {\n\t\t\treturn true, writeStanza(conn, \"fail\")\n\t\t}\n\t\tif err := c.DisplayMessage(name, string(s.Body)); err != nil {\n\t\t\treturn true, writeStanza(conn, \"fail\")\n\t\t}\n\t\treturn true, writeStanza(conn, \"ok\")\n\tcase \"request-secret\", \"request-public\":\n\t\tif c.RequestValue == nil {\n\t\t\treturn true, writeStanza(conn, \"fail\")\n\t\t}\n\t\tsecret, err := c.RequestValue(name, string(s.Body), s.Type == \"request-secret\")\n\t\tif err != nil {\n\t\t\treturn true, writeStanza(conn, \"fail\")\n\t\t}\n\t\treturn true, writeStanzaWithBody(conn, \"ok\", []byte(secret))\n\tcase \"confirm\":\n\t\tif len(s.Args) != 1 && len(s.Args) != 2 {\n\t\t\treturn true, fmt.Errorf(\"malformed confirm stanza: unexpected number of arguments\")\n\t\t}\n\t\tif c.Confirm == nil {\n\t\t\treturn true, writeStanza(conn, \"fail\")\n\t\t}\n\t\tyes, err := format.DecodeString(s.Args[0])\n\t\tif err != nil {\n\t\t\treturn true, fmt.Errorf(\"malformed confirm stanza: invalid YES option encoding\")\n\t\t}\n\t\tvar no []byte\n\t\tif len(s.Args) == 2 {\n\t\t\tno, err = format.DecodeString(s.Args[1])\n\t\t\tif err != nil {\n\t\t\t\treturn true, fmt.Errorf(\"malformed confirm stanza: invalid NO option encoding\")\n\t\t\t}\n\t\t}\n\t\tchoseYes, err := c.Confirm(name, string(s.Body), string(yes), string(no))\n\t\tif err != nil {\n\t\t\treturn true, writeStanza(conn, \"fail\")","sourceCodeStart":342,"sourceCodeEnd":378,"githubUrl":"https://github.com/FiloSottile/age/blob/b74dce4cdbe35b5e5f66c06d9612b72f89028758/plugin/client.go#L342-L378","documentation":"In the client's plugin UI handler, a \"confirm\" stanza from the plugin must carry exactly one or two arguments (the YES option and optionally the NO option, bech32-encoded). A different argument count is rejected as malformed per the age-plugin protocol spec.","triggerScenarios":"A plugin calls ui.Confirm with its protocol message built incorrectly — e.g. sending a confirm stanza with zero arguments or three or more — while the client's Unwrap is dispatching stanzas to handle().","commonSituations":"Custom plugin authors passing empty/extra arguments when emitting the confirm stanza; plugin versions incompatible with the client's protocol implementation.","solutions":["Fix the plugin to send the confirm stanza with exactly one argument (YES) or two (YES and NO), each bech32-encoded","Update the plugin to a spec-conforming release","Inspect the plugin's stanza output (enable debugging or run it manually) to see the malformed argument list"],"exampleFix":"// before (plugin side)\nwriteStanzaWithBody(w, \"confirm\", \"yes\", \"no\", \"maybe\", message)\n// after\nwriteStanzaWithBody(w, \"confirm\", bech32Encode(\"yes\"), bech32Encode(\"no\"), message)","handlingStrategy":"validation","validationCode":"// Plugin-side pre-check before emitting confirm\nif len(args) < 1 || len(args) > 2 { return errors.New(\"confirm needs 1 or 2 bech32 args\") }","typeGuard":null,"tryCatchPattern":"if err := unwrapWithPlugin(); err != nil && strings.Contains(err.Error(), \"malformed confirm stanza\") {\n    return fmt.Errorf(\"plugin %s has a broken confirm implementation; upgrade it\", pluginName)\n}","preventionTips":["Encode confirm options with bech32 before sending","Send 1 arg (YES) or 2 args (YES, NO) — never 0 or 3+","Test interactive plugin flows end-to-end with the official age client"],"tags":["go","age","plugin-protocol","confirm-stanza"],"backgroundTag":"plugin-protocol-violation","analyzedSha":"b74dce4cdbe35b5e5f66c06d9612b72f89028758","analyzedAt":"2026-08-31T23:59:31.627Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}