gastownhall/beads · error

db: DependencySQLRepository.GetWispDependencyRecordsForIDs:

Error message

db: DependencySQLRepository.GetWispDependencyRecordsForIDs: %w

What it means

This error wraps any failure from issueops.GetDependencyRecordsForIssuesForIDs when fetching dependency records for wisp issue IDs from the wisp_dependencies table. The repository deliberately swallows 'table not exist' (returns empty map) so this error signals a real query failure, not a missing wisps schema. The %w preserves the underlying driver error for errors.Is/As inspection.

Source

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

		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. Inspect the wrapped cause with errors.Is/errors.As (e.g. context.Canceled, mysql driver errors) to identify the root failure
  2. Verify DB connectivity and that the wisp_dependencies table exists and matches expected schema (bd migrate / dolt schema check)
  3. Retry with fewer IDs if the batch is very large (query size/placeholder limits)
  4. Check for lock contention from concurrent transactions on wisp_dependencies

Example fix

// before
out, err := repo.GetWispDependencyRecordsForIDs(ctx, hugeIDList)
// after
out, err := repo.GetWispDependencyRecordsForIDs(ctx, ctxValue, chunkIDs(ids, 500))
Defensive patterns

Strategy: try-catch

Validate before calling

if len(wispIDs) == 0 { return map[string][]*types.Dependency{} }
for _, id := range wispIDs {
    if id == "" { return fmt.Errorf("empty wisp ID") }
}

Type guard

func isTableNotExistErr(err error) bool { return dberrors.IsTableNotExist(err) }
func isTransientDBErr(err error) bool {
    return errors.Is(err, context.DeadlineExceeded) || errors.Is(err, context.Canceled) || errors.Is(err, io.ErrUnexpectedEOF)
}

Try / catch

out, err := repo.GetWispDependencyRecordsForIDs(ctx, ids)
if err != nil {
    var derr *go_mysql.MySQLError
    if errors.As(err, &derr) {
        log.Errorf("dependency lookup failed (code %d): %v", derr.Number, derr)
    }
    if isTransientDBErr(err) { retryWithBackoff() }
    return fmt.Errorf("fetching dependencies: %w", err)
}

Prevention

When it happens

Trigger: Calling GetWispDependencyRecordsForIDs when the underlying SQL query fails: malformed wisp IDs causing SQL errors, connection drops mid-query, lock timeouts, or an issueops helper bug. Only non-TableNotExist failures reach this wrapper.

Common situations: Dolt server restarted or connection pool exhausted during a batch dependency lookup; corrupt or oversized wisp ID list causing query errors; schema exists but a driver-level error (context canceled, deadlock) occurs.

Related errors


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