gastownhall/beads · error

CountIssuesByGroup: %w

Error message

CountIssuesByGroup: %w

What it means

Pass-through wrapper from CountIssuesByGroup in the issue use-case: wraps errors from issueRepo.CountIssuesByGroup(ctx, filter, groupBy), which counts issues bucketed by a grouping column (e.g. status, priority, assignee). Failures in the group-by storage query surface as 'CountIssuesByGroup: <root cause>'.

Source

Thrown at internal/storage/domain/issue.go:1841

	out, err := u.issueRepo.GetStatistics(ctx)
	if err != nil {
		return nil, fmt.Errorf("GetStatistics: %w", err)
	}
	return out, nil
}

func (u *issueUseCaseImpl) CountIssues(ctx context.Context, query string, filter types.IssueFilter) (int64, error) {
	out, err := u.issueRepo.CountIssues(ctx, query, filter)
	if err != nil {
		return 0, fmt.Errorf("CountIssues: %w", err)
	}
	return out, nil
}

func (u *issueUseCaseImpl) CountIssuesByGroup(ctx context.Context, filter types.IssueFilter, groupBy string) (map[string]int, error) {
	out, err := u.issueRepo.CountIssuesByGroup(ctx, filter, groupBy)
	if err != nil {
		return nil, fmt.Errorf("CountIssuesByGroup: %w", err)
	}
	return out, nil
}

func (u *issueUseCaseImpl) History(ctx context.Context, id string) ([]*storage.HistoryEntry, error) {
	out, err := u.issueRepo.History(ctx, id)
	if err != nil {
		return nil, fmt.Errorf("History: %w", err)
	}
	return out, nil
}

func (u *issueUseCaseImpl) IterEvents(ctx context.Context, id string, limit int) (storage.Iter[types.Event], error) {
	out, err := u.issueRepo.IterEvents(ctx, id, limit)
	if err != nil {
		return nil, fmt.Errorf("IterEvents: %w", err)
	}
	return out, nil

View on GitHub (pinned to 71377f2769)

Solutions

  1. Inspect the wrapped error after 'CountIssuesByGroup:' for the root cause
  2. Verify groupBy is a supported column name (status, priority, type, assignee, etc.)
  3. Validate IssueFilter values before calling
  4. Retry on transient storage errors

Example fix

// before
groups, err := uc.CountIssuesByGroup(ctx, filter, "priorty")
// after
groups, err := uc.CountIssuesByGroup(ctx, filter, "priority")
Defensive patterns

Strategy: validation

Validate before calling

var validGroups = map[string]bool{"status":true,"priority":true,"type":true,"assignee":true}
if !validGroups[groupBy] {
    return fmt.Errorf("unsupported groupBy: %s", groupBy)
}

Type guard

func validGroupBy(g string) bool {
    switch g {
    case "status", "priority", "type", "assignee":
        return true
    }
    return false
}

Try / catch

groups, err := uc.CountIssuesByGroup(ctx, filter, groupBy)
if err != nil {
    log.Warnf("group counts unavailable for %s: %v", groupBy, err)
    return map[string]int{}
}

Prevention

When it happens

Trigger: Calling CountIssuesByGroup with an unsupported groupBy field name (storage rejects unknown columns) or when the aggregate group query fails due to filter errors or storage outage.

Common situations: Reporting tools passing typo'd groupBy values (e.g. 'priorty' instead of 'priority'); filters referencing nonexistent labels; database unreachable during dashboard refreshes.

Related errors


AI-assisted analysis of gastownhall/beads@71377f2769 (2026-08-30). Data as JSON: /api/errors/8067b88f28822176. Report an issue: GitHub.