{"record":{"id":"ff4cad483cfaf2d8","repo":"jackc/pgx","slug":"cannot-find-encode-plan","errorCode":null,"errorMessage":"cannot find encode plan","messagePattern":"cannot find encode plan","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pgtype/pgtype.go","lineNumber":1989,"sourceCode":"// (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}\n\n\tplan := m.PlanEncode(oid, formatCode, value)\n\tif plan == nil {\n\t\treturn nil, newEncodeError(value, m, oid, formatCode, errors.New(\"cannot find encode plan\"))\n\t}\n\n\tnewBuf, err = plan.Encode(value, buf)\n\tif err != nil {\n\t\treturn nil, newEncodeError(value, m, oid, formatCode, err)\n\t}\n\n\treturn newBuf, nil\n}\n\n// SQLScanner returns a database/sql.Scanner for v. This is necessary for types like Array[T] and Range[T] where the\n// type needs assistance from Map to implement the sql.Scanner interface. It is not necessary for types like Box that\n// implement sql.Scanner directly.\n//\n// This uses the type of v to look up the PostgreSQL OID that v presumably came from. This means v must be registered\n// with m by calling RegisterDefaultPgType.\nfunc (m *Map) SQLScanner(v any) sql.Scanner {\n\tif s, ok := v.(sql.Scanner); ok {","sourceCodeStart":1971,"sourceCodeEnd":2007,"githubUrl":"https://github.com/jackc/pgx/blob/ec1a0befd22592cffffdeeb0a50311b506372f4c/pgtype/pgtype.go#L1971-L2007","documentation":"Map.Encode guard: no encode plan could be produced for the given OID + format code + Go value combination — the value's Go type has no registered codec mapping to that PostgreSQL type in that format. The unsupported (oid, format, type) triple is the faulty input; the more specific error is normally wrapped in an EncodeError carrying the type and OID.","triggerScenarios":"Thrown at pgtype/pgtype.go:1989 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass a Go value whose type is registered for the parameter's PostgreSQL type","Register a custom codec/map for the type via pgtype.Map","Check for mismatched placeholder types in the query vs the arguments"],"exampleFix":null,"handlingStrategy":"type-guard","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"}