{"record":{"id":"d1ad635c53f95b64","repo":"gastownhall/beads","slug":"attaching-s-w","errorCode":null,"errorMessage":"attaching %s: %w","messagePattern":"attaching (.+?): %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/bd/mol_proxied_server.go","lineNumber":139,"sourceCode":"\t\t\tVars:     vars,\n\t\t\tAssignee: in.assignee,\n\t\t\tActor:    actor,\n\t\t\tPrefix:   types.IDPrefixMol,\n\t\t})\n\t\tif err != nil {\n\t\t\treturn pourProxiedResult{}, \"\", fmt.Errorf(\"pouring proto: %w\", err)\n\t\t}\n\n\t\ttotalAttached := 0\n\t\tif len(attachments) > 0 {\n\t\t\tspawnedMol, err := w.GetIssue(ctx, spawnResult.NewEpicID)\n\t\t\tif err != nil {\n\t\t\t\treturn pourProxiedResult{}, \"\", fmt.Errorf(\"loading spawned mol: %w\", err)\n\t\t\t}\n\t\t\tfor _, attach := range attachments {\n\t\t\t\tbondResult, err := bondProtoMolAttachInto(ctx, w, attach.subgraph, attach.issue, spawnedMol, in.attachType, vars, \"\", actor, false, true)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn pourProxiedResult{}, \"\", fmt.Errorf(\"attaching %s: %w\", attach.id, err)\n\t\t\t\t}\n\t\t\t\ttotalAttached += bondResult.Spawned\n\t\t\t}\n\t\t}\n\n\t\treturn pourProxiedResult{spawn: spawnResult, totalAttached: totalAttached, attachCount: len(attachments)},\n\t\t\tfmt.Sprintf(\"bd: mol pour %s\", protoID), nil\n\t})\n\tif err != nil {\n\t\treturn HandleError(\"%v\", err)\n\t}\n\tif res.spawn == nil {\n\t\treturn nil\n\t}\n\n\treturn renderPourResult(res.spawn, res.totalAttached, res.attachCount)\n}\n","sourceCodeStart":121,"sourceCodeEnd":157,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/cmd/bd/mol_proxied_server.go#L121-L157","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Note the attachment ID in the message and run `bd mol show <attachID>` to inspect its proto for var requirements","Supply missing --var values required by the failing attachment's template","Verify the --attach-type is valid and compatible with both the attachment and the spawned mol","Retry after fixing; the pour transaction rolls back fully so state stays consistent"],"exampleFix":"// before\nbd mol pour bd-123 --attach bd-999            // fails: attaching bd-999: missing required var 'region'\n// after\nbd mol pour bd-123 --attach bd-999 --var region=us-east-1","handlingStrategy":"validation","validationCode":"// Pre-check each attachment: it must be a proto and its vars must be satisfiable\nbd mol show <attachID>   // inspect template vars and requirements\nbd mol pour <proto> --attach <attachID> --dry-run","typeGuard":"func attachmentFailed(err error) (attachID string, ok bool) {\n    msg := err.Error()\n    if i := strings.Index(msg, \"attaching \"); i >= 0 {\n        rest := msg[i+len(\"attaching \"):] // \"bd-999: ...\"\n        if j := strings.Index(rest, \":\"); j > 0 {\n            return rest[:j], true\n        }\n    }\n    return \"\", false\n}","tryCatchPattern":"if err := runPourProxiedServer(ctx, in); err != nil {\n    if id, ok := attachmentFailed(err); ok {\n        log.Printf(\"attachment %s failed; re-run pour without it or supply its vars\", id)\n    }\n}","preventionTips":["Always --dry-run pours that use multiple --attach arguments","Supply every required --var for each attachment template up front","Verify each attachment is a real proto (`bd mol show`) before adding it"],"tags":["go","bond","attach","pour","molecule"],"backgroundTag":"proto-attach-bond-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}