vxcontrol/pentagi · error
Assistants.InvalidRequest
Assistants.InvalidRequest
Error message
group field not found
What it means
GetFlowAssistants validates the `group` query parameter against assistantsSQLMappers before running the grouped aggregation. An unrecognized value causes an immediate Assistants.InvalidRequest response with 'group field not found', keeping invalid identifiers out of the generated GROUP BY clause.
Source
Thrown at backend/pkg/server/services/assistants.go:130
}
} else if slices.Contains(privs, "assistants.view") {
scope = func(db *gorm.DB) *gorm.DB {
return db.
Joins("INNER JOIN flows f ON f.id = assistants.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("assistants", assistantsSQLMappers)
if query.Group != "" {
if _, ok := assistantsSQLMappers[query.Group]; !ok {
logger.FromContext(c).Errorf("error finding assistants grouped: group field not found")
response.Error(c, response.ErrAssistantsInvalidRequest, errors.New("group field not found"))
return
}
var respGrouped assistantsGrouped
if respGrouped.Total, err = query.QueryGrouped(s.db, &respGrouped.Grouped, scope); err != nil {
logger.FromContext(c).WithError(err).Errorf("error finding assistants grouped")
response.Error(c, response.ErrInternal, err)
return
}
response.Success(c, http.StatusOK, respGrouped)
return
}
if resp.Total, err = query.Query(s.db, &resp.Assistants, scope); err != nil {
logger.FromContext(c).WithError(err).Errorf("error finding assistants")
response.Error(c, response.ErrInternal, err)
returnView on GitHub (pinned to ea665308ba)
Solutions
- Pick a group value present in assistantsSQLMappers in backend/pkg/server/services/assistants.go
- Consult the endpoint's Swagger documentation for supported group fields
- Drop the group parameter to list assistants without aggregation
- Add the field to assistantsSQLMappers in code if aggregation on it is a legitimate requirement
Example fix
// before GET /api/v1/flows/42/assistants?group=worker_type // after GET /api/v1/flows/42/assistants?group=type (valid mapper key)
Defensive patterns
Strategy: validation
Validate before calling
const assistantsGroups = ["type","status","flow"];
if (group && !assistantsGroups.includes(group)) {
throw new Error(`group must be one of: ${assistantsGroups.join(', ')}`);
} Type guard
function isAssistantsGroup(g: string | undefined): g is typeof assistantsGroups[number] {
return !!g && (assistantsGroups as string[]).includes(g);
} Try / catch
try {
return await api.get(`/flows/${flowId}/assistants`, { params: { group } });
} catch (e) {
if (e.response?.data?.code === 'Assistants.InvalidRequest') {
return await api.get(`/flows/${flowId}/assistants`);
}
throw e;
} Prevention
- Keep per-endpoint group whitelists in one shared file
- Log and surface 400 responses with the requested value for fast diagnosis
- Document groupable fields in the endpoint's Swagger annotations
When it happens
Trigger: GET /flows/{flow_id}/assistants?group=<field> where <field> is not a key in assistantsSQLMappers (typo, wrong casing, or a field that exists on other entities but not assistants).
Common situations: Copy-pasting group parameters from container or assistantlog queries; stale frontend constants after a schema change; API consumers guessing field names from the DB schema.
Related errors
- Assistantlogs.InvalidRequest
- Containers.InvalidRequest
- Internal
- Agentlogs.InvalidRequest
- ErrToolcallsInvalidRequest
AI-assisted analysis of vxcontrol/pentagi@ea665308ba (2026-09-01).
Data as JSON: /api/errors/47bc626897cb07a5.
Report an issue: GitHub.