{"record":{"id":"feff380b212458a4","repo":"jackc/pgx","slug":"range-too-short-v","errorCode":null,"errorMessage":"range too short: %v","messagePattern":"range too short: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pgtype/range.go","lineNumber":209,"sourceCode":"// 16 = (      = 10000\n// 18 = [      = 10010\n// 24 =        = 11000\n\nconst (\n\temptyMask          = 1\n\tlowerInclusiveMask = 2\n\tupperInclusiveMask = 4\n\tlowerUnboundedMask = 8\n\tupperUnboundedMask = 16\n)\n\nfunc parseUntypedBinaryRange(src []byte) (*untypedBinaryRange, error) {\n\tubr := &untypedBinaryRange{}\n\tr := pgio.NewReader(src)\n\n\trangeType := r.Byte()\n\tif r.Err() != nil {\n\t\treturn nil, fmt.Errorf(\"range too short: %v\", len(src))\n\t}\n\n\tif rangeType&emptyMask > 0 {\n\t\tif err := r.Finish(); err != nil {\n\t\t\treturn nil, fmt.Errorf(\"empty range: %w\", err)\n\t\t}\n\t\tubr.LowerType = Empty\n\t\tubr.UpperType = Empty\n\t\treturn ubr, nil\n\t}\n\n\tswitch {\n\tcase rangeType&lowerInclusiveMask > 0:\n\t\tubr.LowerType = Inclusive\n\tcase rangeType&lowerUnboundedMask > 0:\n\t\tubr.LowerType = Unbounded\n\tdefault:\n\t\tubr.LowerType = Exclusive","sourceCodeStart":191,"sourceCodeEnd":227,"githubUrl":"https://github.com/jackc/pgx/blob/ec1a0befd22592cffffdeeb0a50311b506372f4c/pgtype/range.go#L191-L227","documentation":"parseUntypedBinaryRange could not even read the one-byte range flags header from the binary range value; the payload is shorter than a single byte. An empty or truncated binary range from the server is at fault.","triggerScenarios":"Thrown at pgtype/range.go:209 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Treat the value as corrupt binary data and fail the scan","Verify the binary range payload was not truncated in transit","Check that empty/NULL ranges are sent as SQL NULL, not as an empty byte slice"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"ec1a0befd22592cffffdeeb0a50311b506372f4c","analyzedAt":"2026-08-04T22:52:11.263Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}