{"id":"7380d283dc4e8c6b","repo":"jackc/pgx","slug":"unable-to-encode-v","errorCode":null,"errorMessage":"unable to encode %v","messagePattern":"unable to encode (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pgtype/array_codec.go","lineNumber":140,"sourceCode":"\t\t\tbuf = append(buf, ',')\n\t\t}\n\n\t\tfor _, dec := range dimElemCounts {\n\t\t\tif i%dec == 0 {\n\t\t\t\tbuf = append(buf, '{')\n\t\t\t}\n\t\t}\n\n\t\telem := array.Index(i)\n\t\tvar elemBuf []byte\n\t\tisNil, callNilDriverValuer := isNilDriverValuer(elem)\n\t\tif !isNil {\n\t\t\telemType := reflect.TypeOf(elem)\n\t\t\tif lastElemType != elemType {\n\t\t\t\tlastElemType = elemType\n\t\t\t\tencodePlan = p.m.PlanEncode(p.ac.ElementType.OID, TextFormatCode, elem)\n\t\t\t\tif encodePlan == nil {\n\t\t\t\t\treturn nil, fmt.Errorf(\"unable to encode %v\", array.Index(i))\n\t\t\t\t}\n\t\t\t}\n\t\t\telemBuf, err = encodePlan.Encode(elem, inElemBuf)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t} else if callNilDriverValuer {\n\t\t\telemBuf, err = (&encodePlanDriverValuer{m: p.m, oid: p.ac.ElementType.OID, formatCode: TextFormatCode}).Encode(elem, inElemBuf)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t}\n\n\t\tif elemBuf == nil {\n\t\t\tbuf = append(buf, `NULL`...)\n\t\t} else {\n\t\t\tbuf = append(buf, quoteArrayElementIfNeeded(string(elemBuf))...)\n\t\t}","sourceCodeStart":122,"sourceCodeEnd":158,"githubUrl":"https://github.com/jackc/pgx/blob/ec1a0befd22592cffffdeeb0a50311b506372f4c/pgtype/array_codec.go#L122-L158","documentation":"Error \"unable to encode %v\" thrown in jackc/pgx.","triggerScenarios":"Thrown at pgtype/array_codec.go:140 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}