{"record":{"id":"84ea583292c7ee04","repo":"jackc/pgx","slug":"range-lower-bound-cannot-be-null","errorCode":null,"errorMessage":"range lower bound cannot be NULL","messagePattern":"range lower bound cannot be NULL","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pgtype/range.go","lineNumber":242,"sourceCode":"\tcase rangeType&lowerUnboundedMask > 0:\n\t\tubr.LowerType = Unbounded\n\tdefault:\n\t\tubr.LowerType = Exclusive\n\t}\n\n\tswitch {\n\tcase rangeType&upperInclusiveMask > 0:\n\t\tubr.UpperType = Inclusive\n\tcase rangeType&upperUnboundedMask > 0:\n\t\tubr.UpperType = Unbounded\n\tdefault:\n\t\tubr.UpperType = Exclusive\n\t}\n\n\tif ubr.LowerType != Unbounded {\n\t\tval, null := r.Value()\n\t\tif null {\n\t\t\treturn nil, fmt.Errorf(\"range lower bound cannot be NULL\")\n\t\t}\n\t\tubr.Lower = val\n\t}\n\n\tif ubr.UpperType != Unbounded {\n\t\tval, null := r.Value()\n\t\tif null {\n\t\t\treturn nil, fmt.Errorf(\"range upper bound cannot be NULL\")\n\t\t}\n\t\tubr.Upper = val\n\t}\n\n\tif err := r.Finish(); err != nil {\n\t\treturn nil, fmt.Errorf(\"range: %w\", err)\n\t}\n\n\treturn ubr, nil\n}","sourceCodeStart":224,"sourceCodeEnd":260,"githubUrl":"https://github.com/jackc/pgx/blob/ec1a0befd22592cffffdeeb0a50311b506372f4c/pgtype/range.go#L224-L260","documentation":"In the binary range format, a bounded lower bound must be encoded as a non-NULL value (length-prefixed bytes). The reader returned the NULL marker even though the flags byte said the lower bound was bounded — an internally contradictory payload.","triggerScenarios":"Thrown at pgtype/range.go:242 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Treat the binary range as corrupt and reject it","Verify the producer encodes bounded bounds as non-NULL values","Use unbounded flags (or SQL NULL) when a bound is absent"],"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"}