{"record":{"id":"f4f5c338f90af921","repo":"gastownhall/beads","slug":"loading-attachment-s-w","errorCode":null,"errorMessage":"loading attachment %s: %w","messagePattern":"loading attachment (.+?): %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/bd/mol_proxied_server.go","lineNumber":89,"sourceCode":"\t\t\tif err != nil {\n\t\t\t\treturn pourProxiedResult{}, \"\", fmt.Errorf(\"loading proto: %w\", err)\n\t\t\t}\n\t\t}\n\n\t\ttype attachmentInfo struct {\n\t\t\tid       string\n\t\t\tissue    *types.Issue\n\t\t\tsubgraph *TemplateSubgraph\n\t\t}\n\t\tvar attachments []attachmentInfo\n\t\tfor _, attachArg := range in.attachArgs {\n\t\t\tattachID, err := utils.ResolvePartialID(ctx, w, attachArg)\n\t\t\tif err != nil {\n\t\t\t\treturn pourProxiedResult{}, \"\", fmt.Errorf(\"resolving attachment ID %s: %w\", attachArg, err)\n\t\t\t}\n\t\t\tattachIssue, err := w.GetIssue(ctx, attachID)\n\t\t\tif err != nil {\n\t\t\t\treturn pourProxiedResult{}, \"\", fmt.Errorf(\"loading attachment %s: %w\", attachID, err)\n\t\t\t}\n\t\t\tif !isProto(attachIssue) {\n\t\t\t\treturn pourProxiedResult{}, \"\", fmt.Errorf(\"%s is not a proto (missing '%s' label)\", attachID, MoleculeLabel)\n\t\t\t}\n\t\t\tattachSubgraph, err := loadTemplateSubgraph(ctx, w, attachID)\n\t\t\tif err != nil {\n\t\t\t\treturn pourProxiedResult{}, \"\", fmt.Errorf(\"loading attachment subgraph %s: %w\", attachID, err)\n\t\t\t}\n\t\t\tattachments = append(attachments, attachmentInfo{attachID, attachIssue, attachSubgraph})\n\t\t}\n\n\t\tvars := applyVariableDefaults(vars, subgraph)\n\n\t\tvar attachSubgraphs []*TemplateSubgraph\n\t\tfor _, a := range attachments {\n\t\t\tattachSubgraphs = append(attachSubgraphs, a.subgraph)\n\t\t}\n\t\tif err := checkPourVars(subgraph, attachSubgraphs, vars); err != nil {","sourceCodeStart":71,"sourceCodeEnd":107,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/cmd/bd/mol_proxied_server.go#L71-L107","documentation":"After the --attach argument resolves to an ID, bd mol pour loads that attachment issue with GetIssue before validating it. This error wraps a failed load, preserving the cause. The ID resolved, but the issue could not be fetched — storage failure, concurrent deletion, or the attachment being a wisp invisible to GetIssue.","triggerScenarios":"Running `bd mol pour <proto> --attach <id>` where GetIssue fails after successful ID resolution: concurrent deletion of the attachment, Dolt lock/corruption, context timeout, or ephemeral wisp attachments not loadable via the normal issue path.","commonSituations":"Another agent removed the attachment between resolve and load; database locked by concurrent bd commands; attaching an ephemeral issue that gc'ed mid-operation.","solutions":["Re-run the command — transient races/locks often resolve on retry","Confirm the attachment exists: bd show <attachID>","Ensure the attachment is a persistent (non-wisp) issue","Check for and wait out concurrent bd processes holding the DB lock"],"exampleFix":"// before\nattachIssue, err := w.GetIssue(ctx, attachID)\nif err != nil { return fmt.Errorf(\"loading attachment %s: %w\", attachID, err) }\n// after: distinguish not-found from transient\nattachIssue, err := w.GetIssue(ctx, attachID)\nif err != nil {\n\tif errors.Is(err, sql.ErrNoRows) { return fmt.Errorf(\"attachment %s no longer exists\", attachID) }\n\treturn fmt.Errorf(\"loading attachment %s: %w\", attachID, err)\n}","handlingStrategy":"retry","validationCode":"// verify each attachment is loadable before pouring\nfor _, id := range attachIDs {\n\tif _, err := reader.GetIssue(ctx, id); err != nil {\n\t\treturn fmt.Errorf(\"attachment %s not loadable: %w\", id, err)\n\t}\n}","typeGuard":null,"tryCatchPattern":"err := pourCmd(args)\nif err != nil && strings.Contains(err.Error(), \"loading attachment \") {\n\ttime.Sleep(time.Second)\n\terr = pourCmd(args) // retry transient storage failures once\n}","preventionTips":["Avoid deleting attachments while pours using them are running","Use persistent (non-wisp) issues as attachments","Serialize concurrent bd operations to prevent DB locks","Re-check existence with bd show on repeated failures"],"tags":["go","molecule","storage","attachment"],"backgroundTag":"database-query-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}