gastownhall/beads · error

GetForIssueIDs: %w

Error message

GetForIssueIDs: %w

What it means

Wraps a failure from depRepo.ListByIssueIDs when listing outgoing dependencies for a batch of issue IDs from the main (non-wisp) table. GetForIssueIDs builds a per-issue dependency map and this is the first lookup step. Any non-empty-id input reaching a failing repository call produces this error.

Source

Thrown at internal/storage/domain/dependency.go:485

func (u *dependencyUseCaseImpl) ListWithIssueMetadata(ctx context.Context, issueID string, filter DepListFilter) ([]*types.IssueWithDependencyMetadata, error) {
	return u.listWithMetadata(ctx, issueID, filter, false)
}

func (u *dependencyUseCaseImpl) IterWithIssueMetadata(ctx context.Context, issueID string, filter DepListFilter) (storage.Iter[types.IssueWithDependencyMetadata], error) {
	return u.iterWithMetadata(ctx, issueID, filter, false)
}

func (u *dependencyUseCaseImpl) CountByIssueID(ctx context.Context, issueID string, filter DepListFilter) (int64, error) {
	return u.countByID(ctx, issueID, filter, false)
}

func (u *dependencyUseCaseImpl) GetForIssueIDs(ctx context.Context, ids []string) (map[string][]*types.Dependency, error) {
	if len(ids) == 0 {
		return map[string][]*types.Dependency{}, nil
	}
	issueRes, err := u.depRepo.ListByIssueIDs(ctx, ids, DepListOpts{Direction: DepDirectionOut})
	if err != nil {
		return nil, fmt.Errorf("GetForIssueIDs: %w", err)
	}
	out := issueRes.Outgoing
	if out == nil {
		out = make(map[string][]*types.Dependency)
	}
	wispRes, err := u.depRepo.ListByIssueIDs(ctx, ids, DepListOpts{Direction: DepDirectionOut, UseWispsTable: true})
	if err != nil && !dberrors.IsTableNotExist(err) {
		return nil, fmt.Errorf("GetForIssueIDs (wisps): %w", err)
	}
	for id, deps := range wispRes.Outgoing {
		out[id] = append(out[id], deps...)
	}
	return out, nil
}

func (u *dependencyUseCaseImpl) ListByWispIDs(ctx context.Context, wispIDs []string, filter DepListFilter) (DepBulkResult, error) {
	return u.list(ctx, wispIDs, filter, true)
}

View on GitHub (pinned to 71377f2769)

Solutions

  1. Read the wrapped repository error for the root cause
  2. Retry with a smaller id batch if query size limits are suspected
  3. Verify DB connectivity and that migrations created the dependencies table
  4. Ensure the context has an adequate deadline
Defensive patterns

Strategy: try-catch

Validate before calling

if len(ids) == 0 {
	// API already returns an empty map; skip the call
}

Try / catch

depsByIssue, err := u.GetForIssueIDs(ctx, ids)
if err != nil {
	if dberrors.IsTableNotExist(errors.Unwrap(err)) {
		// missing migration; run migrations then retry
	}
	return fmt.Errorf("loading deps: %w", err)
}

Prevention

When it happens

Trigger: Calling GetForIssueIDs with a non-empty ids slice where ListByIssueIDs with Direction DepDirectionOut (main table) returns an error.

Common situations: Database unreachable or schema migration missing; passing malformed/very large ID batches; context timeout during the query.

Related errors


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