{"record":{"id":"ce6ef3f5a2e5993e","repo":"redis/go-redis","slug":"ft-aggregate-each-step-must-set-exactly-one-of-lo","errorCode":null,"errorMessage":"FT.AGGREGATE: each step must set exactly one of Load, Apply, GroupBy, SortBy (got %d)","messagePattern":"FT\\.AGGREGATE: each step must set exactly one of Load, Apply, GroupBy, SortBy \\(got (.+?)\\)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"search_commands.go","lineNumber":725,"sourceCode":"// appendFTAggregateStep appends the Redis command arguments for a single\n// aggregation pipeline step. Each step must set exactly one of Load, Apply,\n// GroupBy or SortBy.\nfunc appendFTAggregateStep(args []interface{}, step FTAggregateStep) ([]interface{}, error) {\n\tset := 0\n\tif step.Load != nil {\n\t\tset++\n\t}\n\tif step.Apply != nil {\n\t\tset++\n\t}\n\tif step.GroupBy != nil {\n\t\tset++\n\t}\n\tif step.SortBy != nil {\n\t\tset++\n\t}\n\tif set != 1 {\n\t\treturn args, fmt.Errorf(\"FT.AGGREGATE: each step must set exactly one of Load, Apply, GroupBy, SortBy (got %d)\", set)\n\t}\n\n\tswitch {\n\tcase step.Load != nil:\n\t\targs = append(args, \"LOAD\")\n\t\tcountIdx := len(args)\n\t\targs = append(args, 0)\n\t\tcount := 0\n\t\targs = append(args, step.Load.Field)\n\t\tcount++\n\t\tif step.Load.As != \"\" {\n\t\t\targs = append(args, \"AS\", step.Load.As)\n\t\t\tcount += 2\n\t\t}\n\t\targs[countIdx] = count\n\tcase step.Apply != nil:\n\t\targs = append(args, \"APPLY\", step.Apply.Field)\n\t\tif step.Apply.As != \"\" {","sourceCodeStart":707,"sourceCodeEnd":743,"githubUrl":"https://github.com/redis/go-redis/blob/c5cad058c72f58370553b48566302303cf8a2e89/search_commands.go#L707-L743","documentation":"Error \"FT.AGGREGATE: each step must set exactly one of Load, Apply, GroupBy, SortBy (got %d)\" thrown in redis/go-redis.","triggerScenarios":"Thrown at search_commands.go:725 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"c5cad058c72f58370553b48566302303cf8a2e89","analyzedAt":"2026-09-01T06:50:53.388Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}