{"id":"f03a6639c724aaee","repo":"jackc/pgx","slug":"mismatched-param-and-argument-count","errorCode":null,"errorMessage":"mismatched param and argument count","messagePattern":"mismatched param and argument count","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"extended_query_builder.go","lineNumber":36,"sourceCode":"\n// Build sets ParamValues, ParamFormats, and ResultFormats for use with *PgConn.ExecParams or *PgConn.ExecPrepared. If\n// sd is nil then QueryExecModeExec behavior will be used.\nfunc (eqb *ExtendedQueryBuilder) Build(m *pgtype.Map, sd *pgconn.StatementDescription, args []any) error {\n\teqb.reset()\n\n\tif sd == nil {\n\t\tfor i := range args {\n\t\t\terr := eqb.appendParam(m, 0, pgtype.TextFormatCode, args[i])\n\t\t\tif err != nil {\n\t\t\t\terr = fmt.Errorf(\"failed to encode args[%d]: %w\", i, err)\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t\treturn nil\n\t}\n\n\tif len(sd.ParamOIDs) != len(args) {\n\t\treturn fmt.Errorf(\"mismatched param and argument count\")\n\t}\n\n\tfor i := range args {\n\t\terr := eqb.appendParam(m, sd.ParamOIDs[i], -1, args[i])\n\t\tif err != nil {\n\t\t\terr = fmt.Errorf(\"failed to encode args[%d]: %w\", i, err)\n\t\t\treturn err\n\t\t}\n\t}\n\n\tfor i := range sd.Fields {\n\t\teqb.appendResultFormat(m.FormatCodeForOID(sd.Fields[i].DataTypeOID))\n\t}\n\n\treturn nil\n}\n\n// appendParam appends a parameter to the query. format may be -1 to automatically choose the format. If arg is nil it","sourceCodeStart":18,"sourceCodeEnd":54,"githubUrl":"https://github.com/jackc/pgx/blob/ec1a0befd22592cffffdeeb0a50311b506372f4c/extended_query_builder.go#L18-L54","documentation":"Error \"mismatched param and argument count\" thrown in jackc/pgx.","triggerScenarios":"Thrown at extended_query_builder.go:36 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}