{"record":{"id":"b646c88de08b2c7e","repo":"vxcontrol/pentagi","slug":"errsubtasksinvalidrequest","errorCode":"ErrSubtasksInvalidRequest","errorMessage":"group field not found","messagePattern":"group field not found","errorType":"http","errorClass":null,"httpStatus":400,"severity":"warning","filePath":"backend/pkg/server/services/subtasks.go","lineNumber":111,"sourceCode":"\t} else if slices.Contains(privs, \"subtasks.view\") {\n\t\tscope = func(db *gorm.DB) *gorm.DB {\n\t\t\treturn db.\n\t\t\t\tJoins(\"INNER JOIN tasks t ON t.id = subtasks.task_id\").\n\t\t\t\tJoins(\"INNER JOIN flows f ON f.id = t.flow_id\").\n\t\t\t\tWhere(\"f.id = ? AND f.user_id = ?\", flowID, uid)\n\t\t}\n\t} else {\n\t\tlogger.FromContext(c).Errorf(\"error filtering user role permissions: permission not found\")\n\t\tresponse.Error(c, response.ErrNotPermitted, nil)\n\t\treturn\n\t}\n\n\tquery.Init(\"subtasks\", subtasksSQLMappers)\n\n\tif query.Group != \"\" {\n\t\tif _, ok := subtasksSQLMappers[query.Group]; !ok {\n\t\t\tlogger.FromContext(c).Errorf(\"error finding subtasks grouped: group field not found\")\n\t\t\tresponse.Error(c, response.ErrSubtasksInvalidRequest, errors.New(\"group field not found\"))\n\t\t\treturn\n\t\t}\n\n\t\tvar respGrouped subtasksGrouped\n\t\tif respGrouped.Total, err = query.QueryGrouped(s.db, &respGrouped.Grouped, scope); err != nil {\n\t\t\tlogger.FromContext(c).WithError(err).Errorf(\"error finding subtasks grouped\")\n\t\t\tresponse.Error(c, response.ErrInternal, err)\n\t\t\treturn\n\t\t}\n\n\t\tresponse.Success(c, http.StatusOK, respGrouped)\n\t\treturn\n\t}\n\n\tif resp.Total, err = query.Query(s.db, &resp.Subtasks, scope); err != nil {\n\t\tlogger.FromContext(c).WithError(err).Errorf(\"error finding subtasks\")\n\t\tresponse.Error(c, response.ErrInternal, err)\n\t\treturn","sourceCodeStart":93,"sourceCodeEnd":129,"githubUrl":"https://github.com/vxcontrol/pentagi/blob/ea665308baaff015b226f308438a68d929d0f29b/backend/pkg/server/services/subtasks.go#L93-L129","documentation":"Returned by the subtasks listing endpoint when a 'group' query parameter is supplied but does not match any field in subtasksSQLMappers. Responds with ErrSubtasksInvalidRequest. Fix by using one of the allowed group fields.","triggerScenarios":"GET /flows/{flow_id}/subtasks?group=<field> where <field> is not a mapped groupable column for subtasks (misspelled, renamed, or never-mapped field).","commonSituations":"Frontend grouping subtasks by a status-like field that is not in the mapper map; clients carrying over group values from the tasks endpoint; backend refactor renamed mapper keys while the client kept the old ones.","solutions":["Choose a group value present in subtasksSQLMappers in backend/pkg/server/services/subtasks.go.","Omit the group parameter to get a regular paginated list.","Update the calling client to the current mapper keys after refactors.","Add the desired column to subtasksSQLMappers if grouping by it is a legitimate requirement."],"exampleFix":"// before\nGET /api/v1/flows/3/subtasks?group=weight\n// after\nGET /api/v1/flows/3/subtasks?group=status","handlingStrategy":"validation","validationCode":"const SUBTASKS_GROUP_FIELDS = ['status', 'created_at']; // keys of subtasksSQLMappers\nif (group && !SUBTASKS_GROUP_FIELDS.includes(group)) {\n  throw new Error(`invalid group field for subtasks: ${group}`);\n}","typeGuard":"function isValidSubtaskGroup(g) {\n  return typeof g === 'string' && SUBTASKS_GROUP_FIELDS.includes(g);\n}","tryCatchPattern":"try {\n  return await api.getFlowSubtasks(flowId, { group });\n} catch (e) {\n  if (e.code === 'ErrSubtasksInvalidRequest' && e.message === 'group field not found') {\n    return await api.getFlowSubtasks(flowId, {});\n  }\n  throw e;\n}","preventionTips":["Match group fields exactly against subtasksSQLMappers keys (case-sensitive).","Do not copy group parameters from the tasks endpoint to subtasks.","Validate the group value client-side before requesting.","Treat this 400 as 'unsupported group field' and retry without grouping."],"tags":["rest-api","validation","query-params","http-400"],"backgroundTag":"invalid-group-field","analyzedSha":"ea665308baaff015b226f308438a68d929d0f29b","analyzedAt":"2026-09-01T14:16:31.421Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}