{"record":{"id":"79fc0a6966f4e08e","repo":"jackc/pgx","slug":"jsonb-too-short","errorCode":null,"errorMessage":"jsonb too short","messagePattern":"jsonb too short","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pgtype/jsonb.go","lineNumber":68,"sourceCode":"\t\t}\n\tcase TextFormatCode:\n\t\treturn (&JSONCodec{Marshal: c.Marshal, Unmarshal: c.Unmarshal}).PlanScan(m, oid, format, target)\n\t}\n\n\treturn nil\n}\n\ntype scanPlanJSONBCodecBinaryUnwrapper struct {\n\ttextPlan ScanPlan\n}\n\nfunc (plan *scanPlanJSONBCodecBinaryUnwrapper) Scan(src []byte, dst any) error {\n\tif src == nil {\n\t\treturn plan.textPlan.Scan(src, dst)\n\t}\n\n\tif len(src) == 0 {\n\t\treturn fmt.Errorf(\"jsonb too short\")\n\t}\n\n\tif src[0] != 1 {\n\t\treturn fmt.Errorf(\"unknown jsonb version number %d\", src[0])\n\t}\n\n\treturn plan.textPlan.Scan(src[1:], dst)\n}\n\nfunc (c *JSONBCodec) DecodeDatabaseSQLValue(m *Map, oid uint32, format int16, src []byte) (driver.Value, error) {\n\tif src == nil {\n\t\treturn nil, nil\n\t}\n\n\tswitch format {\n\tcase BinaryFormatCode:\n\t\tif len(src) == 0 {\n\t\t\treturn nil, fmt.Errorf(\"jsonb too short\")","sourceCodeStart":50,"sourceCodeEnd":86,"githubUrl":"https://github.com/jackc/pgx/blob/ec1a0befd22592cffffdeeb0a50311b506372f4c/pgtype/jsonb.go#L50-L86","documentation":"The binary JSONB wire format prefixes every value with a one-byte version header. This guard fires when a non-NULL jsonb payload in binary format contains zero bytes, so there is no version byte to inspect — the source buffer is truncated below the minimum 1-byte length the format requires.","triggerScenarios":"Thrown at pgtype/jsonb.go:68 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Treat this as data corruption: verify the column really holds jsonb and the binary format was requested correctly","Use text format for the column instead of binary if the server/driver combination produces empty payloads","Check for a truncated or misallocated buffer if the value was produced by custom encoding logic"],"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"}