{"record":{"id":"0f0b9bb2e28a9124","repo":"jackc/pgx","slug":"uint2-w","errorCode":null,"errorMessage":"uint2: %w","messagePattern":"uint2: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pgtype/int.go","lineNumber":336,"sourceCode":"\t} else if n > math.MaxInt8 {\n\t\treturn fmt.Errorf(\"%d is greater than maximum value for int8\", n)\n\t}\n\n\t*p = int8(n)\n\n\treturn nil\n}\n\ntype scanPlanBinaryInt2ToUint8 struct{}\n\nfunc (scanPlanBinaryInt2ToUint8) Scan(src []byte, dst any) error {\n\tif src == nil {\n\t\treturn fmt.Errorf(\"cannot scan NULL into %T\", dst)\n\t}\n\n\traw, err := pgio.Uint16Exact(src)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"uint2: %w\", err)\n\t}\n\n\tp, ok := (dst).(*uint8)\n\tif !ok {\n\t\treturn ErrScanTargetTypeChanged\n\t}\n\n\tn := int16(raw)\n\tif n < 0 {\n\t\treturn fmt.Errorf(\"%d is less than minimum value for uint8\", n)\n\t}\n\n\tif n > math.MaxUint8 {\n\t\treturn fmt.Errorf(\"%d is greater than maximum value for uint8\", n)\n\t}\n\n\t*p = uint8(n)\n","sourceCodeStart":318,"sourceCodeEnd":354,"githubUrl":"https://github.com/jackc/pgx/blob/ec1a0befd22592cffffdeeb0a50311b506372f4c/pgtype/int.go#L318-L354","documentation":"The binary uint2 source is not exactly 2 bytes; pgio.Uint16Exact failed (wrapped with %w). The truncated binary smallint payload from the server is at fault. (Note the message prefix says 'uint2', the unsigned scan plan for int2.)","triggerScenarios":"Thrown at pgtype/int.go:336 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Treat as protocol/data corruption — verify the column is smallint","Check for driver/server version mismatch"],"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"}