gastownhall/beads · error

molecule %s not found: %w

Error message

molecule %s not found: %w

What it means

When a molecule ID has no parent-child dependent issues, GetMoleculeLastActivity falls back to loading the root issue itself. If GetIssue also fails (typically not found), the code wraps it as 'molecule <id> not found'. So the ID passed in resolved to no children AND no loadable root issue — effectively the molecule does not exist or is unreadable.

Source

Thrown at cmd/bd/mol_port.go:314

func (r uowMolReader) GetMoleculeLastActivity(ctx context.Context, moleculeID string) (*types.MoleculeLastActivity, error) {
	dependents, err := r.GetDependentsWithMetadata(ctx, moleculeID)
	if err != nil {
		return nil, fmt.Errorf("get molecule children: %w", err)
	}

	var children []types.Issue
	for _, dependent := range dependents {
		if dependent.DependencyType != types.DepParentChild {
			continue
		}
		children = append(children, dependent.Issue)
	}

	if len(children) == 0 {
		root, err := r.GetIssue(ctx, moleculeID)
		if err != nil {
			return nil, fmt.Errorf("molecule %s not found: %w", moleculeID, err)
		}
		return &types.MoleculeLastActivity{
			MoleculeID:   moleculeID,
			LastActivity: root.UpdatedAt,
			Source:       "molecule_updated",
		}, nil
	}

	var lastUpdatedAt time.Time
	var lastUpdatedID string
	var lastClosedAt time.Time
	var lastClosedID string
	haveClosed := false

	for _, child := range children {
		if child.UpdatedAt.After(lastUpdatedAt) {
			lastUpdatedAt = child.UpdatedAt
			lastUpdatedID = child.ID

View on GitHub (pinned to 71377f2769)

Solutions

  1. Run bd list or bd show <id> to confirm the molecule ID exists in the current database
  2. Re-run from the correct repository/directory so the right .beads database is used
  3. Check for typos or stale partial IDs; use the full ID copied from bd output
  4. If the molecule was deleted, re-create it (bd mol pour or bd create) rather than querying its last activity

Example fix

// before: blind call
last, _ := reader.GetMoleculeLastActivity(ctx, "bd-123")
// after: verify existence first
if _, err := reader.GetIssue(ctx, "bd-123"); err != nil {
	return fmt.Errorf("molecule bd-123 does not exist: %w", err)
}
last, err := reader.GetMoleculeLastActivity(ctx, "bd-123")
Defensive patterns

Strategy: validation

Validate before calling

// confirm the molecule exists before computing last activity
if _, err := reader.GetIssue(ctx, moleculeID); err != nil {
	return fmt.Errorf("molecule %s does not exist here", moleculeID)
}

Try / catch

last, err := reader.GetMoleculeLastActivity(ctx, molID)
if err != nil && strings.Contains(err.Error(), "not found") {
	// fall back to listing molecules to pick a valid ID
	return fmt.Errorf("unknown molecule %q; run `bd mol list`", molID)
}

Prevention

When it happens

Trigger: Calling bd mol last-activity with a molecule ID that (a) has no DepParentChild dependents and (b) whose root issue cannot be fetched — ID typo, partial ID that resolves wrongly, molecule deleted/closed and purged, or storage error on the root lookup.

Common situations: Typo or stale prefix in the molecule ID (e.g. referencing bd-123 after it was deleted); running in the wrong repo/database so the ID isn't present; referencing a wisp/ephemeral issue that was garbage-collected; passing a non-molecule leaf issue that has no children and then also failing lookup under a different database.

Related errors


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