gastownhall/beads · error
count by id: %w
Error message
count by id: %w
What it means
Wraps a repository failure from depRepo.CountByID after the empty-ID guard. The dependency count query failed at the storage layer; the root cause is preserved via %w.
Source
Thrown at internal/storage/domain/dependency.go:557
UseWispsTable: useWisp,
})
if err != nil {
return nil, fmt.Errorf("iter dep metadata: %w", err)
}
return it, nil
}
func (u *dependencyUseCaseImpl) countByID(ctx context.Context, sourceID string, filter DepListFilter, useWisp bool) (int64, error) {
if sourceID == "" {
return 0, fmt.Errorf("count by id: sourceID must not be empty")
}
n, err := u.depRepo.CountByID(ctx, sourceID, DepListOpts{
Types: filter.Types,
Direction: filter.Direction,
UseWispsTable: useWisp,
})
if err != nil {
return 0, fmt.Errorf("count by id: %w", err)
}
return n, nil
}
func (u *dependencyUseCaseImpl) list(ctx context.Context, ids []string, filter DepListFilter, useWisp bool) (DepBulkResult, error) {
if len(ids) == 0 {
return DepBulkResult{
Outgoing: map[string][]*types.Dependency{},
Incoming: map[string][]*types.Dependency{},
}, nil
}
out, err := u.depRepo.ListByIssueIDs(ctx, ids, DepListOpts{
Types: filter.Types,
Direction: filter.Direction,
UseWispsTable: useWisp,
})
if err != nil {
return DepBulkResult{}, fmt.Errorf("list deps: %w", err)View on GitHub (pinned to 71377f2769)
Solutions
- Read the wrapped cause; handle transient DB errors with retry/backoff
- Verify migrations and table presence for the wisp variant
- Simplify the filter (e.g. drop Types/Direction constraints) to isolate the failing query
- Check context deadline adequacy
Defensive patterns
Strategy: retry
Validate before calling
if sourceID == "" {
return fmt.Errorf("sourceID required")
} Try / catch
n, err := u.CountByIssueID(ctx, sourceID, filter)
if err != nil {
if isTransient(errors.Unwrap(err)) {
// exponential backoff retry; counts are read-only
}
return 0, err
} Prevention
- Apply backoff retry for transient DB errors
- Verify wisps table for CountByWispID deployments
- Reduce filter complexity if count queries time out
- Keep migrations aligned with the beads version
When it happens
Trigger: Calling CountByIssueID or CountByWispID with a valid sourceID where CountByID on depRepo returns an error (with the filter's Types/Direction/UseWispsTable applied).
Common situations: DB outage or lock contention; count query timeout on nodes with very large dependency fan-out; wisps variant when the wisps table is absent or inconsistent.
Related errors
- reparent: remove old parent %s: %w
- reparent: add new parent %s: %w
- GetForIssueIDs: %w
- GetForIssueIDs (wisps): %w
- list dep metadata: %w
AI-assisted analysis of gastownhall/beads@71377f2769 (2026-08-30).
Data as JSON: /api/errors/439168fe0c2692a2.
Report an issue: GitHub.