{"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":"Error \"cannot find encode plan\" thrown in jackc/pgx.","triggerScenarios":"Thrown at pgtype/pgtype.go:1989 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}