vxcontrol/pentagi · warning
Agentlogs.InvalidRequest
Agentlogs.InvalidRequest
Error message
group field not found
What it means
GetAgentlogs validates the ?group= query parameter against agentlogsSQLMappers before calling QueryGrouped; if the requested field is not a known mapper key it returns an AgentlogsInvalidRequest (400-style) response with this message. This mirrors the rdb layer check but produces a client-facing invalid-request error instead of an internal error.
Source
Thrown at backend/pkg/server/services/agentlogs.go:100
}
} else if slices.Contains(privs, "agentlogs.view") {
scope = func(db *gorm.DB) *gorm.DB {
return db.
Joins("INNER JOIN flows f ON f.id = flow_id").
Where("f.user_id = ?", uid)
}
} else {
logger.FromContext(c).Errorf("error filtering user role permissions: permission not found")
response.Error(c, response.ErrNotPermitted, nil)
return
}
query.Init("agentlogs", agentlogsSQLMappers)
if query.Group != "" {
if _, ok := agentlogsSQLMappers[query.Group]; !ok {
logger.FromContext(c).Errorf("error finding agentlogs grouped: group field not found")
response.Error(c, response.ErrAgentlogsInvalidRequest, errors.New("group field not found"))
return
}
var respGrouped agentlogsGrouped
if respGrouped.Total, err = query.QueryGrouped(s.db, &respGrouped.Grouped, scope); err != nil {
logger.FromContext(c).WithError(err).Errorf("error finding agentlogs grouped")
response.Error(c, response.ErrInternal, err)
return
}
response.Success(c, http.StatusOK, respGrouped)
return
}
if resp.Total, err = query.Query(s.db, &resp.AgentLogs, scope); err != nil {
logger.FromContext(c).WithError(err).Errorf("error finding agentlogs")
response.Error(c, response.ErrInternal, err)
returnView on GitHub (pinned to ea665308ba)
Solutions
- Send a supported group value, e.g. ?group=flow_id or ?group=created_at.
- Update the frontend to offer only fields present in agentlogsSQLMappers.
- If the field should be groupable, add it to agentlogsSQLMappers as a string SQL expression.
- Handle the Agentlogs.InvalidRequest response code in the client and show a validation message.
Example fix
// before GET /agentlogs?group=log_level // not a mapper key -> 400 invalid request // after GET /agentlogs?group=initiator // valid mapper key
Defensive patterns
Strategy: validation
Validate before calling
const agentlogGroupFields = ["id","initiator","executor","task","result","flow_id","task_id","subtask_id","created_at"];
if (params.group && !agentlogGroupFields.includes(params.group)) {
return res.status(400).json({ code: "AgentlogsInvalidRequest" });
} Type guard
function isAgentlogGroupField(v) { return typeof v === "string" && agentlogGroupFields.includes(v); } Try / catch
try { const r = await api.get('/agentlogs', { params }); }
catch (e) { if (e.response?.data?.code === 'Agentlogs.InvalidRequest') resetGroupFilter(); else throw e; } Prevention
- Whitelist group fields client-side before sending.
- Keep frontend field lists in sync with agentlogsSQLMappers.
- Use snake_case names exactly as defined server-side.
- Handle the InvalidRequest error code with a user-facing message.
When it happens
Trigger: GET /agentlogs?group=<field> where <field> is not one of the allowed keys: id, initiator, executor, task, result, flow_id, task_id, subtask_id, created_at, data.
Common situations: Frontend grouping dropdown sends a stale or renamed field; API user guesses field names from the JSON payload instead of the mapper list; version skew where frontend was updated before backend.
Related errors
- Assistantlogs.InvalidRequest
- Assistants.InvalidRequest
- Containers.InvalidRequest
- ErrToolcallsInvalidRequest
- ErrUsersInvalidRequest
AI-assisted analysis of vxcontrol/pentagi@ea665308ba (2026-09-01).
Data as JSON: /api/errors/61c4dde7d8d06808.
Report an issue: GitHub.