{"id":"b7ac61817efac943","repo":"jackc/pgx","slug":"unable-to-encode-v-into-s-format-for-s-oid-d","errorCode":null,"errorMessage":"unable to encode %#v into %s format for %s (OID %d): %w","messagePattern":"unable to encode %#v into (.+?) format for (.+?) \\(OID (.+?)\\): %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pgtype/pgtype.go","lineNumber":1967,"sourceCode":"func newEncodeError(value any, m *Map, oid uint32, formatCode int16, err error) error {\n\tvar format string\n\tswitch formatCode {\n\tcase TextFormatCode:\n\t\tformat = \"text\"\n\tcase BinaryFormatCode:\n\t\tformat = \"binary\"\n\tdefault:\n\t\tformat = fmt.Sprintf(\"unknown (%d)\", formatCode)\n\t}\n\n\tvar dataTypeName string\n\tif t, ok := m.TypeForOID(oid); ok {\n\t\tdataTypeName = t.Name\n\t} else {\n\t\tdataTypeName = \"unknown type\"\n\t}\n\n\treturn fmt.Errorf(\"unable to encode %#v into %s format for %s (OID %d): %w\", value, format, dataTypeName, oid, err)\n}\n\n// Encode appends the encoded bytes of value to buf. If value is the SQL value NULL then append nothing and return\n// (nil, nil). The caller of Encode is responsible for writing the correct NULL value or the length of the data\n// written.\nfunc (m *Map) Encode(oid uint32, formatCode int16, value any, buf []byte) (newBuf []byte, err error) {\n\tif isNil, callNilDriverValuer := isNilDriverValuer(value); isNil {\n\t\tif callNilDriverValuer {\n\t\t\tnewBuf, err = (&encodePlanDriverValuer{m: m, oid: oid, formatCode: formatCode}).Encode(value, buf)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, newEncodeError(value, m, oid, formatCode, err)\n\t\t\t}\n\n\t\t\treturn newBuf, nil\n\t\t} else {\n\t\t\treturn nil, nil\n\t\t}\n\t}","sourceCodeStart":1949,"sourceCodeEnd":1985,"githubUrl":"https://github.com/jackc/pgx/blob/ec1a0befd22592cffffdeeb0a50311b506372f4c/pgtype/pgtype.go#L1949-L1985","documentation":"Error \"unable to encode %#v into %s format for %s (OID %d): %w\" thrown in jackc/pgx.","triggerScenarios":"Thrown at pgtype/pgtype.go:1967 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}