vxcontrol/pentagi · warning
ErrSubtasksInvalidRequest
ErrSubtasksInvalidRequest
Error message
group field not found
What it means
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.
Source
Thrown at backend/pkg/server/services/subtasks.go:111
} else if slices.Contains(privs, "subtasks.view") {
scope = func(db *gorm.DB) *gorm.DB {
return db.
Joins("INNER JOIN tasks t ON t.id = subtasks.task_id").
Joins("INNER JOIN flows f ON f.id = t.flow_id").
Where("f.id = ? AND f.user_id = ?", flowID, uid)
}
} else {
logger.FromContext(c).Errorf("error filtering user role permissions: permission not found")
response.Error(c, response.ErrNotPermitted, nil)
return
}
query.Init("subtasks", subtasksSQLMappers)
if query.Group != "" {
if _, ok := subtasksSQLMappers[query.Group]; !ok {
logger.FromContext(c).Errorf("error finding subtasks grouped: group field not found")
response.Error(c, response.ErrSubtasksInvalidRequest, errors.New("group field not found"))
return
}
var respGrouped subtasksGrouped
if respGrouped.Total, err = query.QueryGrouped(s.db, &respGrouped.Grouped, scope); err != nil {
logger.FromContext(c).WithError(err).Errorf("error finding subtasks grouped")
response.Error(c, response.ErrInternal, err)
return
}
response.Success(c, http.StatusOK, respGrouped)
return
}
if resp.Total, err = query.Query(s.db, &resp.Subtasks, scope); err != nil {
logger.FromContext(c).WithError(err).Errorf("error finding subtasks")
response.Error(c, response.ErrInternal, err)
returnView on GitHub (pinned to ea665308ba)
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.
Example fix
// before GET /api/v1/flows/3/subtasks?group=weight // after GET /api/v1/flows/3/subtasks?group=status
Defensive patterns
Strategy: validation
Validate before calling
const SUBTASKS_GROUP_FIELDS = ['status', 'created_at']; // keys of subtasksSQLMappers
if (group && !SUBTASKS_GROUP_FIELDS.includes(group)) {
throw new Error(`invalid group field for subtasks: ${group}`);
} Type guard
function isValidSubtaskGroup(g) {
return typeof g === 'string' && SUBTASKS_GROUP_FIELDS.includes(g);
} Try / catch
try {
return await api.getFlowSubtasks(flowId, { group });
} catch (e) {
if (e.code === 'ErrSubtasksInvalidRequest' && e.message === 'group field not found') {
return await api.getFlowSubtasks(flowId, {});
}
throw e;
} Prevention
- 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.
When it happens
Trigger: GET /flows/{flow_id}/subtasks?group=<field> where <field> is not a mapped groupable column for subtasks (misspelled, renamed, or never-mapped field).
Common situations: 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.
Related errors
- ErrScreenshotsInvalidRequest
- ErrSearchlogsInvalidRequest
- ErrTasksInvalidRequest
- ErrTermlogsInvalidRequest
- Internal
AI-assisted analysis of vxcontrol/pentagi@ea665308ba (2026-09-01).
Data as JSON: /api/errors/b646c88de08b2c7e.
Report an issue: GitHub.