gastownhall/beads · error

db: DependencySQLRepository.GetDependencyRecordsForIssues: %

Error message

db: DependencySQLRepository.GetDependencyRecordsForIssues: %w

What it means

GetDependencyRecordsForIssues calls issueops.GetDependencyRecordsForIssuesInTx to fetch dependency records grouped per issue ID. Empty input returns an empty map without touching the database, so this wrapper only fires for non-empty ID lists where the underlying batch query failed: SQL error, connection loss, or scan failure.

Source

Thrown at internal/storage/domain/db/dependency.go:970

// WispSourceIDs classifies a batch of ids by plane in one scoped query. It is
// the proxied twin of the in-tx probe the store-backed dependency editor runs,
// and shares its implementation so the two answer the same question — down to
// treating a missing wisps table as "no wisps" rather than an error.
func (r *dependencySQLRepositoryImpl) WispSourceIDs(ctx context.Context, ids []string) (map[string]struct{}, error) {
	set, err := issueops.WispIDSetInTx(ctx, r.runner, ids)
	if err != nil {
		return nil, fmt.Errorf("db: DependencySQLRepository.WispSourceIDs: %w", err)
	}
	return set, nil
}

func (r *dependencySQLRepositoryImpl) GetDependencyRecordsForIssues(ctx context.Context, issueIDs []string) (map[string][]*types.Dependency, error) {
	if len(issueIDs) == 0 {
		return map[string][]*types.Dependency{}, nil
	}
	out, err := issueops.GetDependencyRecordsForIssuesInTx(ctx, r.runner, issueIDs)
	if err != nil {
		return nil, fmt.Errorf("db: DependencySQLRepository.GetDependencyRecordsForIssues: %w", err)
	}
	return out, nil
}

func (r *dependencySQLRepositoryImpl) GetWispDependencyRecordsForIDs(ctx context.Context, wispIDs []string) (map[string][]*types.Dependency, error) {
	if len(wispIDs) == 0 {
		return map[string][]*types.Dependency{}, nil
	}
	out, err := issueops.GetDependencyRecordsForIssuesFromTableInTx(ctx, r.runner, "wisp_dependencies", wispIDs)
	if err != nil {
		if dberrors.IsTableNotExist(err) {
			return map[string][]*types.Dependency{}, nil
		}
		return nil, fmt.Errorf("db: DependencySQLRepository.GetWispDependencyRecordsForIDs: %w", err)
	}
	return out, nil
}

View on GitHub (pinned to 71377f2769)

Solutions

  1. Unwrap the error for the root SQL/driver cause.
  2. Split very large issueID lists into smaller batches before calling.
  3. Verify connectivity and schema; retry transient failures.
  4. Check the dependencies table integrity with doctor/repair tooling.

Example fix

// before: one giant batch
recs, err := repo.GetDependencyRecordsForIssues(ctx, allIDs)
// after: chunk the batch
for i := 0; i < len(allIDs); i += 500 {
    end := min(i+500, len(allIDs))
    part, err := repo.GetDependencyRecordsForIssues(ctx, allIDs[i:end])
    if err != nil { return fmt.Errorf("records batch %d: %w", i, err) }
    merge(recs, part)
}
Defensive patterns

Strategy: validation

Validate before calling

if len(issueIDs) == 0 {
    return map[string][]*types.Dependency{} // library short-circuits empty input
}
if len(issueIDs) > 1000 {
    return errors.New("batch too large; split into chunks of <=1000 IDs")
}

Type guard

func isBatchable(ids []string) bool { return len(ids) > 0 && len(ids) <= 1000 }

Try / catch

recs, err := repo.GetDependencyRecordsForIssues(ctx, ids)
if err != nil {
    if errors.Is(errors.Unwrap(err), driver.ErrBadConn) {
        // retry with a fresh connection/context
        return repo.GetDependencyRecordsForIssues(freshCtx, ids)
    }
    return fmt.Errorf("dep records: %w", err)
}

Prevention

When it happens

Trigger: Calling GetDependencyRecordsForIssues(ctx, issueIDs) with non-empty issueIDs where GetDependencyRecordsForIssuesInTx errors: dependencies table unreadable, connection dropped, context cancellation, oversized batch hitting engine limits.

Common situations: Rendering dependency views for many issues at once against a slow or restarted Dolt server; schema drift after upgrade; batch size exceeding IN-clause/engine limits.

Understand the failure class

Background: "query failed", "%w: SQL error" — wrapped database query errors in Go libraries explained — this error's family across 3 libraries.

Related errors


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