gastownhall/beads · error

no database connection

Error message

no database connection

What it means

squashMolecule requires a non-nil DoltStorage handle. If called with nil storage it returns 'no database connection'. This is a guard against invoking squash without an open database session (e.g., in tests or before initialization).

Source

Thrown at cmd/bd/mol_squash.go:243

			}
			sb.WriteString(fmt.Sprintf("   %s\n", desc))
		}
		if child.CloseReason != "" {
			sb.WriteString(fmt.Sprintf("   *Outcome: %s*\n", child.CloseReason))
		}
		sb.WriteString("\n")
	}

	return sb.String()
}

// squashMolecule performs the squash operation
// If summary is provided (non-empty), it's used as the digest content.
// Otherwise, generateDigest() creates a basic concatenation.
// This enables agents to provide AI-generated summaries while keeping bd as a pure tool.
func squashMolecule(ctx context.Context, s storage.DoltStorage, root *types.Issue, children []*types.Issue, keepChildren bool, summary string, actorName string) (*SquashResult, error) {
	if s == nil {
		return nil, fmt.Errorf("no database connection")
	}

	var result *SquashResult
	err := transact(ctx, s, fmt.Sprintf("bd: squash molecule %s", root.ID), func(tx storage.Transaction) error {
		r, err := squashMoleculeInto(ctx, storeMolWriter{DoltStorage: s, tx: tx}, root, children, keepChildren, summary, actorName)
		if err != nil {
			return err
		}
		result = r
		return nil
	})
	if err != nil {
		return nil, err
	}
	return result, nil
}

func squashMoleculeInto(ctx context.Context, w molWriter, root *types.Issue, children []*types.Issue, keepChildren bool, summary string, actorName string) (*SquashResult, error) {

View on GitHub (pinned to 71377f2769)

Solutions

  1. Ensure bd init (or equivalent) created the database before running bd mol squash
  2. Check that storage opened successfully earlier in the command; fix any init errors surfaced there
  3. In tests/automation, construct and pass a real DoltStorage instance instead of nil

Example fix

// before
var s storage.DoltStorage // nil
result, err := squashMolecule(ctx, s, root, children, true, "", actor)
// after
s, err := storage.Open(ctx)
if err != nil { return err }
result, err := squashMolecule(ctx, s, root, children, true, "", actor)
Defensive patterns

Strategy: validation

Validate before calling

if s == nil {
    return fmt.Errorf("no database connection: run bd init first")
}

Type guard

func hasStorage(s storage.DoltStorage) bool { return s != nil }

Try / catch

result, err := squashMolecule(ctx, s, root, children, keep, summary, actor)
if err != nil {
    if err.Error() == "no database connection" {
        return fmt.Errorf("open the database (bd init / storage.Open) before squash")
    }
    return err
}

Prevention

When it happens

Trigger: Calling squashMolecule programmatically (or via runMolSquash paths) before storage initialization succeeds, or when database open/connect was skipped or failed silently upstream.

Common situations: Running bd mol squash in an environment with no .beads database initialized; embedded mode not set up; tests passing a nil storage stub.

Related errors


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