gastownhall/beads · error
get dependencies: rows from %s: %w
Error message
get dependencies: rows from %s: %w
What it means
This error wraps a failure reported by rows.Err() while iterating dependency rows for an issue in GetDependenciesWithMetadataInTx. The driver-level query succeeded initially, but the row stream hit an error mid-iteration (connection drop, context cancellation, driver decode failure) on one of the two dependency tables ("dependencies" or "wisp_dependencies"). The %s names which table was being read so you can tell whether regular or wisp dependency rows failed.
Source
Thrown at internal/storage/issueops/dependencies.go:1122
// Query both dependency tables to find all dependencies.
var deps []depMeta
for _, depTable := range []string{"dependencies", "wisp_dependencies"} {
rows, err := tx.QueryContext(ctx, fmt.Sprintf(
`SELECT %s AS depends_on_id, type FROM %s WHERE issue_id = ?`, DepTargetExpr, depTable), issueID)
if err != nil {
return nil, fmt.Errorf("get dependencies from %s: %w", depTable, err)
}
for rows.Next() {
var d depMeta
if scanErr := rows.Scan(&d.depID, &d.depType); scanErr != nil {
_ = rows.Close()
return nil, fmt.Errorf("get dependencies: scan: %w", scanErr)
}
deps = append(deps, d)
}
_ = rows.Close()
if err := rows.Err(); err != nil {
return nil, fmt.Errorf("get dependencies: rows from %s: %w", depTable, err)
}
}
if len(deps) == 0 {
return nil, nil
}
// Fetch all dependency target issues.
ids := make([]string, len(deps))
for i, d := range deps {
ids[i] = d.depID
}
issues, err := GetIssuesByIDsInTx(ctx, tx, ids, nil)
if err != nil {
return nil, fmt.Errorf("get dependencies: fetch issues: %w", err)
}
issueMap := make(map[string]*types.Issue, len(issues))
for _, iss := range issues {View on GitHub (pinned to 71377f2769)
Solutions
- Check the wrapped driver error in the %w chain for connection/context issues and inspect the named table ("dependencies" vs "wisp_dependencies").
- Ensure the context passed in has an adequate deadline; avoid cancelling the request mid-traversal.
- Verify DB connectivity/stability (keepalives, connection pool settings like ConnMaxLifetime).
- Retry the operation on a fresh transaction if the wrapped error is transient (connection reset, driver: bad connection).
Example fix
// before: no deadline management, long tree walk killed mid-rows
ctx := context.Background()
deps, err := GetDependenciesWithMetadataInTx(ctx, tx, issueID)
// after: give the traversal a sane deadline and handle transient errors
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
defer cancel()
deps, err := GetDependenciesWithMetadataInTx(ctx, tx, issueID)
if err != nil && isTransient(err) { deps, err = retry(...) } Defensive patterns
Strategy: try-catch
Validate before calling
// Ensure a healthy connection and adequate deadline before the call
if err := tx.PingContext(ctx); err != nil { return err }
ctx, cancel := context.WithTimeout(ctx, 30*time.Second)
defer cancel() Type guard
func isRowsIterationErr(err error) bool {
return err != nil && strings.Contains(err.Error(), "rows from ")
} Try / catch
deps, err := GetDependenciesWithMetadataInTx(ctx, tx, issueID)
if err != nil {
var netErr net.Error
if errors.As(err, &netErr) || errors.Is(err, context.DeadlineExceeded) {
return retryWithFreshTx(ctx, issueID)
}
return fmt.Errorf("dependency metadata lookup failed: %w", err)
} Prevention
- Always pass a context with a realistic timeout for dependency traversals.
- Keep ConnMaxLifetime below the server wait_timeout to avoid reaped connections.
- Check rows-scoped errors at the source: log the wrapped driver error, not just the wrapper.
- Monitor connection-pool health in long-running services.
When it happens
Trigger: Calling GetDependenciesWithMetadataInTx (via buildDependencyTreeInTx or ExecuteRelated) when the underlying SQL connection dies or the context is cancelled while rows from dependencies/wisp_dependencies are still being drained.
Common situations: Long dependency-tree traversals whose connection times out mid-scan; user Ctrl-C or deadline expiry cancelling ctx mid-iteration; flaky network to a remote Dolt/MySQL server; driver errors surfaced lazily by database/sql only at rows.Err().
Related errors
- db: ChildCounterSQLRepository.NextChildID: rows: %w
- db: CommentSQLRepository.CountsByIssueIDs: rows: %w
- db: CommentSQLRepository.ListByIssueIDs: rows: %w
- get dependents: rows from %s: %w
- failed to begin transaction: %w
AI-assisted analysis of gastownhall/beads@71377f2769 (2026-08-30).
Data as JSON: /api/errors/b240999d84a6ae78.
Report an issue: GitHub.