gastownhall/beads · error

get ready work: compute deferred parent children: %w

Error message

get ready work: compute deferred parent children: %w

What it means

Wraps failures from getChildrenOfDeferredParents while buildReadyWorkPredicates assembles the ID sets for the ready-work WHERE clause. When a work filter does not include deferred items, the library must first find children of currently-deferred parents to exclude them. If that probe/query fails, get ready work cannot produce a trustworthy ready list and aborts with this wrap.

Source

Thrown at internal/storage/domain/db/ready_work.go:35

}

// buildReadyWorkOrder orders by the sort_* aliases projected by
// sqlbuild.UnionSortColumnsSQL, since ready work always sorts at the UNION
// outer query here.
func buildReadyWorkOrder(policy types.SortPolicy) sqlbuild.ReadyWorkOrder {
	return sqlbuild.BuildReadyWorkOrder(policy, "sort_created", "sort_priority")
}

// buildReadyWorkPredicates computes the ID sets the ready-work WHERE clause
// needs (children of deferred parents, parent descendants), then delegates
// the clause text to sqlbuild so both stacks share ready semantics. Unlike
// the classic stack, ORDER BY and LIMIT are applied at the UNION outer query.
func (r *issueSQLRepositoryImpl) buildReadyWorkPredicates(ctx context.Context, filter types.WorkFilter, tables filterTables) (*readyWorkPredicates, error) {
	var inputs sqlbuild.ReadyWorkWhereInputs
	if !filter.IncludeDeferred {
		deferredChildIDs, dcErr := r.getChildrenOfDeferredParents(ctx)
		if dcErr != nil {
			return nil, fmt.Errorf("get ready work: compute deferred parent children: %w", dcErr)
		}
		inputs.DeferredChildIDs = deferredChildIDs
	}
	if filter.ParentID != nil {
		descendantIDs, descErr := r.getDescendantIDs(ctx, *filter.ParentID, 0)
		if descErr != nil {
			return nil, fmt.Errorf("get parent descendants: %w", descErr)
		}
		inputs.ParentDescendantIDs = descendantIDs
	}

	whereSQL, args, err := sqlbuild.BuildReadyWorkWhere(filter, tables, inputs)
	if err != nil {
		return nil, err
	}
	return &readyWorkPredicates{whereSQL: whereSQL, args: args}, nil
}

View on GitHub (pinned to 71377f2769)

Solutions

  1. Check the wrapped cause ("deferred parents: ...") for the underlying SQL error
  2. Verify core tables (issues, wisps, dependencies, wisp_dependencies) exist in the database
  3. Retry if transient connectivity; check server health
  4. As a workaround, call with IncludeDeferred=true to skip deferred-parent computation

Example fix

// before: failing filter
filter := types.WorkFilter{} // IncludeDeferred=false triggers the deferred-parent pass
// after: skip deferred-parent computation when acceptable
filter := types.WorkFilter{IncludeDeferred: true}
Defensive patterns

Strategy: try-catch

Validate before calling

// verify core tables before computing ready work
for _, t := range []string{"issues", "wisps", "dependencies", "wisp_dependencies"} {
	var c int
	err := db.QueryRow("SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = DATABASE() AND table_name = ?", t).Scan(&c)
	if err != nil || c == 0 { return fmt.Errorf("missing table %s", t) }
}

Type guard

func isDeferredChildrenError(err error) bool {
	return err != nil && strings.Contains(err.Error(), "compute deferred parent children")
}

Try / catch

ready, err := repo.GetReadyWork(ctx, filter)
if isDeferredChildrenError(err) {
	// fall back to including deferred items, which skips this computation
	filter.IncludeDeferred = true
	ready, err = repo.GetReadyWork(ctx, filter)
}

Prevention

When it happens

Trigger: Calling bd ready / GetReadyWork with IncludeDeferred=false while the deferred-parent existence probe or the deferred-children queries fail (connection error, missing table that is not an optional wisp table, SQL error).

Common situations: Schema drift where `issues`/`dependencies` tables are missing or renamed; DB connectivity problems during ready-work computation; engine errors in the deferred-parent probe queries.

Related errors


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