gastownhall/beads · error

checking %s.id for the pre-0058 repair: %w

Error message

checking %s.id for the pre-0058 repair: %w

What it means

Wraps a failure from schemaColumnExists when checking whether wisp_dependencies already has an `id` column, which decides whether the pre-0058 repair must add the surrogate key. The column-existence metadata query failed; the repair aborts rather than guessing the table's shape. Called from repairWispDependenciesForwardShape via wispDepNeedsForwardRepair.

Source

Thrown at internal/storage/schema/wisp_dep_forward_repair.go:189

// depends_on_id nor id, which no lineage produces on purpose and which only a
// process killed between this repair's DROP COLUMN and its ADD COLUMN can
// reach. Detecting the second is what makes the repair resumable rather than
// leaving a keyless table behind for 0058 to complete over.
//
// A fresh store has id and no generated column and is not repaired: 0058
// applies to it cleanly, and the constraints are already there from creation.
func wispDepNeedsForwardRepair(ctx context.Context, db DBConn) (bool, error) {
	generated, err := wispDepHasStoredGeneratedDependsOnID(ctx, db)
	if err != nil {
		return false, err
	}
	if generated {
		return true, nil
	}

	hasID, err := schemaColumnExists(ctx, db, wispDepTable, "id")
	if err != nil {
		return false, fmt.Errorf("checking %s.id for the pre-0058 repair: %w", wispDepTable, err)
	}
	if hasID {
		// Final lineage. Still finish the job if a prior pass was killed
		// between adding the surrogate key and adding every constraint: the
		// steps below are individually guarded, so this is a no-op once the
		// shape is complete.
		return wispDepMissingAnyFinalConstraint(ctx, db)
	}

	// Neither depends_on_id nor id: a mid-rebuild crash. Resume.
	return true, nil
}

func wispDepMissingAnyFinalConstraint(ctx context.Context, db DBConn) (bool, error) {
	for _, c := range wispDepFinalConstraints {
		present, err := schemaConstraintExists(ctx, db, wispDepTable, c.name)
		if err != nil {
			return false, err

View on GitHub (pinned to 71377f2769)

Solutions

  1. Inspect the wrapped cause (%w) — typically a connection or privilege error.
  2. Reconnect and re-run; every repair step is individually guarded so the repair resumes safely.
  3. Grant the DB user SELECT on information_schema.
  4. If wisp_dependencies metadata is unreadable/corrupt, restore from backup or re-init from the .beads/issues.jsonl export.

Example fix

// before
hasID, err := schemaColumnExists(...) // checking wisp_dependencies.id ... driver: bad connection
// after
if err := db.PingContext(ctx); err != nil {
    return fmt.Errorf("db unreachable before repair: %w", err)
}
if err := repairWispDependenciesForwardShape(ctx, db); err != nil {
    return err
}
Defensive patterns

Strategy: try-catch

Validate before calling

var hasID bool
rows, err := db.QueryContext(ctx, `SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_NAME = 'wisp_dependencies' AND COLUMN_NAME = 'id'`)
if err == nil && rows.Next() {
    _ = rows.Scan(&hasID)
}
rows.Close()
_ = hasID // metadata readable; safe to proceed with repair

Try / catch

err := repairWispDependenciesForwardShape(ctx, db)
if err != nil && strings.Contains(err.Error(), "checking wisp_dependencies.id") {
    // metadata probe failed: reconnect and retry once
    if err := db.PingContext(ctx); err == nil {
        err = repairWispDependenciesForwardShape(ctx, db)
    }
}
return err

Prevention

When it happens

Trigger: wispDepNeedsForwardRepair calls schemaColumnExists(ctx, db, "wisp_dependencies", "id") and the information_schema column lookup errors (connection failure, permission denial, table metadata unreadable).

Common situations: Dropped connection mid-upgrade; restricted DB user cannot read COLUMNS metadata; Dolt server under load timing out on metadata queries during startup migration.

Related errors


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