{"record":{"id":"b5b326786a9f5983","repo":"FiloSottile/age","slug":"data-part-too-short","errorCode":null,"errorMessage":"data part too short","messagePattern":"data part too short","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/bech32/bech32.go","lineNumber":170,"sourceCode":"\tfor p, c := range hrp {\n\t\tif c < 33 || c > 126 {\n\t\t\treturn \"\", nil, fmt.Errorf(\"invalid character human-readable part: s[%d]=%d\", p, c)\n\t\t}\n\t}\n\tfor p, c := range s[pos+1:] {\n\t\t// Fold ASCII explicitly. Unicode case folding can turn a non-ASCII\n\t\t// rune into a shorter valid charset member.\n\t\tif c >= 'A' && c <= 'Z' {\n\t\t\tc += 'a' - 'A'\n\t\t}\n\t\td := strings.IndexRune(charset, c)\n\t\tif d == -1 {\n\t\t\treturn \"\", nil, fmt.Errorf(\"invalid character data part: s[%d]=%v\", p, c)\n\t\t}\n\t\tdata = append(data, byte(d))\n\t}\n\tif len(data) < 6 {\n\t\treturn \"\", nil, fmt.Errorf(\"data part too short\")\n\t}\n\tif !verifyChecksum(hrp, data) {\n\t\treturn \"\", nil, fmt.Errorf(\"invalid checksum\")\n\t}\n\tdata, err = convertBits(data[:len(data)-6], 5, 8, false)\n\tif err != nil {\n\t\treturn \"\", nil, err\n\t}\n\treturn hrp, data, nil\n}\n","sourceCodeStart":152,"sourceCodeEnd":181,"githubUrl":"https://github.com/FiloSottile/age/blob/b74dce4cdbe35b5e5f66c06d9612b72f89028758/internal/bech32/bech32.go#L152-L181","documentation":"A valid bech32 string needs at least 6 data-part characters (the checksum) beyond the HRP. If fewer than 6 characters follow the separator, there is not even a full checksum to verify, so Decode fails early.","triggerScenarios":"Decode with strings like \"age1q\" or \"hrp12345\" (only 5 data chars) — anything with len(s)-pos-1 < 6.","commonSituations":"Truncated keys from copy/paste or message length limits, hand-trimmed strings that cut the tail of an address.","solutions":["Re-copy the complete key; the string was truncated","Check that log/UI truncation (e.g. '...') did not remove the tail","Validate length before decoding: last '1' + 7 chars minimum"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if len(s)-strings.LastIndex(s, \"1\")-1 < 6 {\n    return errors.New(\"bech32 data part too short; input likely truncated\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Check key lengths after copy/paste (age recipients are long, fixed-ish shapes)","Beware UI/log truncation with ellipses","Fail fast with a length check before decoding"],"tags":["bech32","decoding","truncation"],"backgroundTag":"bech32-separator-invalid","analyzedSha":"b74dce4cdbe35b5e5f66c06d9612b72f89028758","analyzedAt":"2026-08-31T23:59:31.627Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}