{"id":"1ab6effb9d9c18a8","repo":"jackc/pgx","slug":"upper-cannot-be-null-unless-uppertype-is-unbounded","errorCode":null,"errorMessage":"Upper cannot be NULL unless UpperType is Unbounded","messagePattern":"Upper cannot be NULL unless UpperType is Unbounded","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pgtype/range_codec.go","lineNumber":134,"sourceCode":"\t\tlowerPlan := plan.m.PlanEncode(plan.rc.ElementType.OID, BinaryFormatCode, lower)\n\t\tif lowerPlan == nil {\n\t\t\treturn nil, fmt.Errorf(\"cannot encode %v as element of range\", lower)\n\t\t}\n\n\t\tbuf, err = lowerPlan.Encode(lower, buf)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to encode %v as element of range: %w\", lower, err)\n\t\t}\n\t\tif buf == nil {\n\t\t\treturn nil, fmt.Errorf(\"Lower cannot be NULL unless LowerType is Unbounded\")\n\t\t}\n\n\t\tpgio.SetInt32(buf[sp:], int32(len(buf[sp:])-4))\n\t}\n\n\tif upperType != Unbounded {\n\t\tif upper == nil {\n\t\t\treturn nil, fmt.Errorf(\"Upper cannot be NULL unless UpperType is Unbounded\")\n\t\t}\n\n\t\tsp := len(buf)\n\t\tbuf = pgio.AppendInt32(buf, -1)\n\n\t\tupperPlan := plan.m.PlanEncode(plan.rc.ElementType.OID, BinaryFormatCode, upper)\n\t\tif upperPlan == nil {\n\t\t\treturn nil, fmt.Errorf(\"cannot encode %v as element of range\", upper)\n\t\t}\n\n\t\tbuf, err = upperPlan.Encode(upper, buf)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to encode %v as element of range: %w\", upper, err)\n\t\t}\n\t\tif buf == nil {\n\t\t\treturn nil, fmt.Errorf(\"Upper cannot be NULL unless UpperType is Unbounded\")\n\t\t}\n","sourceCodeStart":116,"sourceCodeEnd":152,"githubUrl":"https://github.com/jackc/pgx/blob/ec1a0befd22592cffffdeeb0a50311b506372f4c/pgtype/range_codec.go#L116-L152","documentation":"Error \"Upper cannot be NULL unless UpperType is Unbounded\" thrown in jackc/pgx.","triggerScenarios":"Thrown at pgtype/range_codec.go:134 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"analyzedSha":"ec1a0befd22592cffffdeeb0a50311b506372f4c","analyzedAt":"2026-08-04T22:52:11.263Z","schemaVersion":2}