{"id":"a73d1bfe645bb49a","repo":"jackc/pgx","slug":"failed-to-encode-args-d-w","errorCode":null,"errorMessage":"failed to encode args[%d]: %w","messagePattern":"failed to encode args\\[(.+?)\\]: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"extended_query_builder.go","lineNumber":28,"sourceCode":"// ExtendedQueryBuilder is used to choose the parameter formats, to format the parameters and to choose the result\n// formats for an extended query.\ntype ExtendedQueryBuilder struct {\n\tParamValues     [][]byte\n\tparamValueBytes []byte\n\tParamFormats    []int16\n\tResultFormats   []int16\n}\n\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","sourceCodeStart":10,"sourceCodeEnd":46,"githubUrl":"https://github.com/jackc/pgx/blob/ec1a0befd22592cffffdeeb0a50311b506372f4c/extended_query_builder.go#L10-L46","documentation":"Error \"failed to encode args[%d]: %w\" thrown in jackc/pgx.","triggerScenarios":"Thrown at extended_query_builder.go:28 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}