{"record":{"id":"be87a4f3c5fbc490","repo":"jackc/pgx","slug":"range-upper-bound-cannot-be-null","errorCode":null,"errorMessage":"range upper bound cannot be NULL","messagePattern":"range upper bound cannot be NULL","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pgtype/range.go","lineNumber":250,"sourceCode":"\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}\n\n// Range is a generic range type.\ntype Range[T any] struct {\n\tLower     T\n\tUpper     T\n\tLowerType BoundType\n\tUpperType BoundType\n\tValid     bool","sourceCodeStart":232,"sourceCodeEnd":268,"githubUrl":"https://github.com/jackc/pgx/blob/ec1a0befd22592cffffdeeb0a50311b506372f4c/pgtype/range.go#L232-L268","documentation":"The binary range's upper bound is marked bounded by the flags byte, but its wire encoding is NULL (negative length prefix) — a contradiction between the flags and the payload. Symmetric to the lower-bound check.","triggerScenarios":"Thrown at pgtype/range.go:250 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Reject the malformed binary range value","Ensure the encoder sets the unbounded flag instead of writing NULL for missing bounds","Log the payload to trace which producer is inconsistent"],"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"}