Wei-Shaw/sub2api · error
failed to get group statistics
Error message
failed to get group statistics
What it means
Returned while assembling the v2 dashboard snapshot when includeGroups is true and h.getGroupStatsCached(...) fails. The group statistics aggregation over the window failed; the specific cause is lost because only the generic message is returned. Infrastructure-side failure.
Source
Thrown at backend/internal/handler/admin/dashboard_snapshot_v2_handler.go:234
resp.Models = models
}
if includeGroups {
groups, _, err := h.getGroupStatsCached(
ctx,
startTime,
endTime,
filters.UserID,
filters.APIKeyID,
filters.AccountID,
filters.GroupID,
filters.RequestType,
filters.Stream,
filters.BillingType,
filters.UpstreamModelMismatch,
)
if err != nil {
return nil, errors.New("failed to get group statistics")
}
resp.Groups = groups
}
if includeUsersTrend {
usersTrend, _, err := h.getUserUsageTrendCached(ctx, startTime, endTime, granularity, usersTrendLimit)
if err != nil {
return nil, errors.New("failed to get user usage trend")
}
resp.UsersTrend = usersTrend
}
return resp, nil
}
func parseDashboardSnapshotV2Filters(c *gin.Context) (*dashboardSnapshotV2Filters, error) {
filters := &dashboardSnapshotV2Filters{
Model: strings.TrimSpace(c.Query("model")),View on GitHub (pinned to 073e92d171)
Solutions
- Retry after a short backoff
- Reduce the date range or apply user/key filters to shrink the aggregation
- Check backend logs for the underlying group-stats error
- Request the snapshot without the groups section as a workaround
Defensive patterns
Strategy: retry
Try / catch
// TS
let groups;
try { groups = (await getSnapshotV2({ includeGroups: true, start, end })).groups; }
catch (e) {
if (e.message === 'failed to get group statistics') {
groups = (await withBackoff(() => getSnapshotV2({ includeGroups: true, start, end }))).groups;
} else throw e;
} Prevention
- Retry group-stats snapshot failures with backoff
- Keep group counts manageable and filter by user/key where possible
- Fetch sections independently so one failure does not kill the whole dashboard
When it happens
Trigger: GET dashboard snapshot v2 with the groups section included while the group-stats query fails (DB outage, timeout, lock contention).
Common situations: Instances with very many groups making the aggregation large; concurrent snapshot requests; DB resource limits.
Related errors
- failed to get dashboard statistics
- failed to get usage trend
- failed to get model statistics
- failed to get user usage trend
- HTTP error! status: ${response.status}
AI-assisted analysis of Wei-Shaw/sub2api@073e92d171 (2026-08-15).
Data as JSON: /api/errors/b9ba045bd9a70146.
Report an issue: GitHub.