gastownhall/beads · error
db: DependencySQLRepository.DeleteAllForIDs rows affected: %
Error message
db: DependencySQLRepository.DeleteAllForIDs rows affected: %w
What it means
DeleteAllForIDs batches a DELETE across dependency tables, then calls res.RowsAffected() to tally how many rows each batch removed. This error wraps a failure of RowsAffected() itself — the DELETE statement succeeded, but the driver could not report the row count. It is a driver/database-metadata failure, not a SQL failure, so the deletes may have already been applied.
Source
Thrown at internal/storage/domain/db/dependency.go:777
ph := strings.Join(placeholders, ",")
// Journal the edges this batch is about to remove, while they and their
// source snapshots are still readable.
if err := issueops.RecordDependencyRemovalsForTableInTx(ctx, r.runner, table, batch); err != nil {
return total, fmt.Errorf("db: DependencySQLRepository.DeleteAllForIDs journal removals from %s: %w", table, err)
}
//nolint:gosec // G201: table is one of two hardcoded constants; ? placeholders only.
res, err := r.runner.ExecContext(ctx,
fmt.Sprintf("DELETE FROM %s WHERE issue_id IN (%s) OR %s IN (%s)", table, ph, issueops.DepTargetExpr, ph),
args...)
if err != nil {
if opts.UseWispsTable && dberrors.IsTableNotExist(err) {
return total, nil
}
return total, fmt.Errorf("db: DependencySQLRepository.DeleteAllForIDs from %s: %w", table, err)
}
n, err := res.RowsAffected()
if err != nil {
return total, fmt.Errorf("db: DependencySQLRepository.DeleteAllForIDs rows affected: %w", err)
}
total += int(n)
}
return total, nil
}
func (r *dependencySQLRepositoryImpl) CountAllForIDs(ctx context.Context, ids []string, opts domain.DepCountsOpts) (int, error) {
if len(ids) == 0 {
return 0, nil
}
table := "dependencies"
if opts.UseWispsTable {
table = "wisp_dependencies"
}
total := 0
for start := 0; start < len(ids); start += deleteBatchSize {
end := start + deleteBatchSize
if end > len(ids) {View on GitHub (pinned to 71377f2769)
Solutions
- Check the configured storage driver implements database/sql RowsAffected correctly; use the supported dolthub/driver-based driver.
- Upgrade/verify the database driver version for known RowsAffected bugs.
- Retry the operation — the deletes may have partially applied; verify counts with CountAllForIDs afterward.
- If writing a custom driver via the driver interface, return a result that implements RowsAffected.
Example fix
// before: custom driver returns sql.Result without RowsAffected support
// after: implement RowsAffected on your driver result
type result struct{ rows int64 }
func (r result) RowsAffected() (int64, error) { return r.rows, nil }
func (r result) LastInsertId() (int64, error) { return 0, nil } Defensive patterns
Strategy: retry
Validate before calling
// verify driver supports RowsAffected before bulk delete
var probe any = driverResult // your driver result
if _, ok := probe.(interface{ RowsAffected() (int64, error) }); !ok {
return errors.New("driver result does not implement RowsAffected")
} Type guard
func supportsRowsAffected(r driver.Result) bool {
_, err := r.RowsAffected()
return err == nil
} Try / catch
n, err := repo.DeleteAllForIDs(ctx, ids, opts)
var re *retryableError
if errors.As(err, &re) || isTransient(err) {
// retry with backoff; deletes may have partially applied
verified, _ := repo.CountAllForIDs(ctx, ids, opts)
_ = verified
} Prevention
- Always use the supported dolthub/driver-based storage driver.
- Keep the database driver updated for known RowsAffected bugs.
- After a failed delete tally, re-count rows to verify actual state before retrying.
When it happens
Trigger: Calling DependencySQLRepository.DeleteAllForIDs(ctx, ids, opts) where the underlying driver's ExecContext result cannot compute RowsAffected — e.g. a driver whose result type does not implement RowsAffected, or a driver error surfaced only when reading the affected-row count.
Common situations: Running against a non-Dolt/unsupported driver substituted behind the storage driver interface; driver version changes that alter result metadata handling; a closed or broken connection between ExecContext returning and RowsAffected being read.
Related errors
- failed to check rows affected for issue counter prefix %q: %
- failed to check rows affected after seeding for prefix %q: %
- db: EventsSQLRepository.DeleteAllForIDs rows affected: %w
- db: Update %s: rows affected: %w
- db: Claim %s: rows affected: %w
AI-assisted analysis of gastownhall/beads@71377f2769 (2026-08-30).
Data as JSON: /api/errors/3b93418ccb26265f.
Report an issue: GitHub.