{"id":"28a8406ab574bb23","repo":"jackc/pgx","slug":"expected-d-values-got-d-values","errorCode":null,"errorMessage":"expected %d values, got %d values","messagePattern":"expected (.+?) values, got (.+?) values","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"copy_from.go","lineNumber":230,"sourceCode":"\t}\n\n\treturn commandTag.RowsAffected(), err\n}\n\nfunc (ct *copyFrom) buildCopyBuf(buf []byte, sd *pgconn.StatementDescription) (bool, []byte, error) {\n\tconst sendBufSize = 65536 - 5 // The packet has a 5-byte header\n\tlastBufLen := 0\n\tlargestRowLen := 0\n\n\tfor ct.rowSrc.Next() {\n\t\tlastBufLen = len(buf)\n\n\t\tvalues, err := ct.rowSrc.Values()\n\t\tif err != nil {\n\t\t\treturn false, nil, err\n\t\t}\n\t\tif len(values) != len(ct.columnNames) {\n\t\t\treturn false, nil, fmt.Errorf(\"expected %d values, got %d values\", len(ct.columnNames), len(values))\n\t\t}\n\n\t\tbuf = pgio.AppendInt16(buf, int16(len(ct.columnNames)))\n\t\tfor i, val := range values {\n\t\t\tbuf, err = encodeCopyValue(ct.conn.typeMap, buf, sd.Fields[i].DataTypeOID, val)\n\t\t\tif err != nil {\n\t\t\t\treturn false, nil, err\n\t\t\t}\n\t\t}\n\n\t\trowLen := len(buf) - lastBufLen\n\t\tif rowLen > largestRowLen {\n\t\t\tlargestRowLen = rowLen\n\t\t}\n\n\t\t// Try not to overflow size of the buffer PgConn.CopyFrom will be reading into. If that happens then the nature of\n\t\t// io.Pipe means that the next Read will be short. This can lead to pathological send sizes such as 65531, 13, 65531\n\t\t// 13, 65531, 13, 65531, 13.","sourceCodeStart":212,"sourceCodeEnd":248,"githubUrl":"https://github.com/jackc/pgx/blob/ec1a0befd22592cffffdeeb0a50311b506372f4c/copy_from.go#L212-L248","documentation":"Error \"expected %d values, got %d values\" thrown in jackc/pgx.","triggerScenarios":"Thrown at copy_from.go:230 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}