{"record":{"id":"69d748fc53755018","repo":"FiloSottile/age","slug":"malformed-body-line-q-stanza-ended-without-a-sho","errorCode":null,"errorMessage":"malformed body line %q: stanza ended without a short line\nnote: this might be a file encrypted with an old beta version of age or rage; use age v1.0.0-beta6 or rage to decrypt it","messagePattern":"malformed body line %q: stanza ended without a short line\nnote: this might be a file encrypted with an old beta version of age or rage; use age v1\\.0\\.0-beta6 or rage to decrypt it","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/format/format.go","lineNumber":213,"sourceCode":"\t\treturn nil, fmt.Errorf(\"malformed stanza opening line: %q\", line)\n\t}\n\tprefix, args := splitArgs(line)\n\tif prefix != string(stanzaPrefix) || len(args) < 1 {\n\t\treturn nil, fmt.Errorf(\"malformed stanza: %q\", line)\n\t}\n\ts.Type = args[0]\n\ts.Args = args[1:]\n\n\tfor {\n\t\tline, err := r.r.ReadBytes('\\n')\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to read line: %w\", err)\n\t\t}\n\n\t\tb, err := DecodeString(strings.TrimSuffix(string(line), \"\\n\"))\n\t\tif err != nil {\n\t\t\tif bytes.HasPrefix(line, footerPrefix) || bytes.HasPrefix(line, stanzaPrefix) {\n\t\t\t\treturn nil, fmt.Errorf(\"malformed body line %q: stanza ended without a short line\\nnote: this might be a file encrypted with an old beta version of age or rage; use age v1.0.0-beta6 or rage to decrypt it\", line)\n\t\t\t}\n\t\t\treturn nil, errorf(\"malformed body line %q: %v\", line, err)\n\t\t}\n\t\tif len(b) > BytesPerLine {\n\t\t\treturn nil, errorf(\"malformed body line %q: too long\", line)\n\t\t}\n\t\ts.Body = append(s.Body, b...)\n\t\tif len(b) < BytesPerLine {\n\t\t\t// A stanza body always ends with a short line.\n\t\t\treturn s, nil\n\t\t}\n\t}\n}\n\ntype ParseError struct {\n\terr error\n}\n","sourceCodeStart":195,"sourceCodeEnd":231,"githubUrl":"https://github.com/FiloSottile/age/blob/b74dce4cdbe35b5e5f66c06d9612b72f89028758/internal/format/format.go#L195-L231","documentation":"A stanza body line failed base64 decoding, and the line itself started with a footer or stanza prefix — meaning a new stanza/footer began without the mandatory short (empty-ish) line that terminates the previous stanza. The message notes files produced by age v1.0.0-beta1–5, which lacked that short line.","triggerScenarios":"format.ReadStanza decodes a body line, DecodeString fails, and bytes.HasPrefix(line, footerPrefix) || bytes.HasPrefix(line, stanzaPrefix) is true — a stanza ended without a short line.","commonSituations":"Decrypting files generated by old beta versions (age < v1.0.0-beta6 or matching rage betas); hand-edited header files; corruption that made a short line disappear.","solutions":["Decrypt the file with age v1.0.0-beta6 or rage (as the note suggests), re-encrypt with a current version","Upgrade the encrypting tool so all new files use the stable v1 format","If the file is current-format, treat this as corruption: re-transfer the file","Do not hand-edit age headers; regenerate instead"],"exampleFix":"// before\n$ age -d -i key.txt file.age   # fails: malformed body line \"---\": stanza ended without a short line\n// after\n$ rage file.age > out.txt      # or age v1.0.0-beta6\n$ age -e -r <new-pubkey> out.txt > file-v1.age","handlingStrategy":"validation","validationCode":"head, _ := bufio.NewReader(f).Peek(64)\n// beta age files look similar but stanzas lack the short terminator line\nif !bytes.HasPrefix(head, []byte(\"age-encryption.org/v1\")) { return errors.New(\"not a v1 age file\") }","typeGuard":"var pe *age.ParseError\nif errors.As(err, &pe) && strings.Contains(pe.Error(), \"old beta version\") { /* legacy beta format */ }","tryCatchPattern":null,"preventionTips":["Encrypt with a current stable age release","Archive files with the encrypting tool's version metadata","Never hand-edit age headers; regenerate files instead"],"tags":["format","header-parsing","backwards-compatibility","beta-version"],"backgroundTag":"legacy-file-format","analyzedSha":"b74dce4cdbe35b5e5f66c06d9612b72f89028758","analyzedAt":"2026-08-31T23:59:31.627Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}