gastownhall/beads · error

attaching %s: %w

Error message

attaching %s: %w

What it means

Wrapped error from bondProtoMolAttachInto for one specific attachment during `bd mol pour`. The message identifies which attachment ID (attach.id) failed to be cloned and bonded into the freshly spawned molecule. Earlier attachments may have already been bonded, but the whole pour transaction rolls back on failure.

Source

Thrown at cmd/bd/mol_proxied_server.go:139

			Vars:     vars,
			Assignee: in.assignee,
			Actor:    actor,
			Prefix:   types.IDPrefixMol,
		})
		if err != nil {
			return pourProxiedResult{}, "", fmt.Errorf("pouring proto: %w", err)
		}

		totalAttached := 0
		if len(attachments) > 0 {
			spawnedMol, err := w.GetIssue(ctx, spawnResult.NewEpicID)
			if err != nil {
				return pourProxiedResult{}, "", fmt.Errorf("loading spawned mol: %w", err)
			}
			for _, attach := range attachments {
				bondResult, err := bondProtoMolAttachInto(ctx, w, attach.subgraph, attach.issue, spawnedMol, in.attachType, vars, "", actor, false, true)
				if err != nil {
					return pourProxiedResult{}, "", fmt.Errorf("attaching %s: %w", attach.id, err)
				}
				totalAttached += bondResult.Spawned
			}
		}

		return pourProxiedResult{spawn: spawnResult, totalAttached: totalAttached, attachCount: len(attachments)},
			fmt.Sprintf("bd: mol pour %s", protoID), nil
	})
	if err != nil {
		return HandleError("%v", err)
	}
	if res.spawn == nil {
		return nil
	}

	return renderPourResult(res.spawn, res.totalAttached, res.attachCount)
}

View on GitHub (pinned to 71377f2769)

Solutions

  1. Note the attachment ID in the message and run `bd mol show <attachID>` to inspect its proto for var requirements
  2. Supply missing --var values required by the failing attachment's template
  3. Verify the --attach-type is valid and compatible with both the attachment and the spawned mol
  4. Retry after fixing; the pour transaction rolls back fully so state stays consistent

Example fix

// before
bd mol pour bd-123 --attach bd-999            // fails: attaching bd-999: missing required var 'region'
// after
bd mol pour bd-123 --attach bd-999 --var region=us-east-1
Defensive patterns

Strategy: validation

Validate before calling

// Pre-check each attachment: it must be a proto and its vars must be satisfiable
bd mol show <attachID>   // inspect template vars and requirements
bd mol pour <proto> --attach <attachID> --dry-run

Type guard

func attachmentFailed(err error) (attachID string, ok bool) {
    msg := err.Error()
    if i := strings.Index(msg, "attaching "); i >= 0 {
        rest := msg[i+len("attaching "):] // "bd-999: ..."
        if j := strings.Index(rest, ":"); j > 0 {
            return rest[:j], true
        }
    }
    return "", false
}

Try / catch

if err := runPourProxiedServer(ctx, in); err != nil {
    if id, ok := attachmentFailed(err); ok {
        log.Printf("attachment %s failed; re-run pour without it or supply its vars", id)
    }
}

Prevention

When it happens

Trigger: Run `bd mol pour <proto> --attach a --attach b` where loading the spawned mol succeeded but bonding attachment (e.g. `b`) fails: template var mismatches between attachment and pour vars, dependency-cycle creation, or a storage write error while cloning the attachment subgraph.

Common situations: Attachment proto requires --var values not supplied; attach type invalid for the target; attachment subgraph references issues that no longer exist; storage failure partway through the multi-attachment loop.

Related errors


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