{"record":{"id":"a4f828e5ff1d3de5","repo":"jackc/pgx","slug":"unknown-format-code-d-a4f828","errorCode":null,"errorMessage":"unknown format code %d","messagePattern":"unknown format code (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pgtype/multirange.go","lineNumber":301,"sourceCode":"func (spac *scanPlanMultirangeCodec) Scan(src []byte, dst any) error {\n\tc := spac.multirangeCodec\n\tm := spac.m\n\toid := spac.oid\n\tformatCode := spac.formatCode\n\n\tmultirange := dst.(MultirangeSetter)\n\n\tif src == nil {\n\t\treturn multirange.ScanNull()\n\t}\n\n\tswitch formatCode {\n\tcase BinaryFormatCode:\n\t\treturn c.decodeBinary(m, oid, src, multirange)\n\tcase TextFormatCode:\n\t\treturn c.decodeText(m, oid, src, multirange)\n\tdefault:\n\t\treturn fmt.Errorf(\"unknown format code %d\", formatCode)\n\t}\n}\n\nfunc (c *MultirangeCodec) 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 TextFormatCode:\n\t\treturn string(src), nil\n\tcase BinaryFormatCode:\n\t\tbuf := make([]byte, len(src))\n\t\tcopy(buf, src)\n\t\treturn buf, nil\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"unknown format code %d\", format)\n\t}","sourceCodeStart":283,"sourceCodeEnd":319,"githubUrl":"https://github.com/jackc/pgx/blob/ec1a0befd22592cffffdeeb0a50311b506372f4c/pgtype/multirange.go#L283-L319","documentation":"The multirange scan plan dispatches on the result format code captured at plan time, handling only binary and text. This is the default-branch guard: it fires when the stored format code is neither known value, which in practice means a corrupt format code reached the plan from the connection or query configuration.","triggerScenarios":"Thrown at pgtype/multirange.go:301 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check query/result format configuration for invalid format codes","Report as a driver bug since PostgreSQL only defines text and binary formats","Upgrade pgx to the latest version"],"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"}