{"record":{"id":"2754732d21490e73","repo":"gastownhall/beads","slug":"molecule-s-not-found-w","errorCode":null,"errorMessage":"molecule %s not found: %w","messagePattern":"molecule (.+?) not found: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/bd/mol_port.go","lineNumber":314,"sourceCode":"\nfunc (r uowMolReader) GetMoleculeLastActivity(ctx context.Context, moleculeID string) (*types.MoleculeLastActivity, error) {\n\tdependents, err := r.GetDependentsWithMetadata(ctx, moleculeID)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"get molecule children: %w\", err)\n\t}\n\n\tvar children []types.Issue\n\tfor _, dependent := range dependents {\n\t\tif dependent.DependencyType != types.DepParentChild {\n\t\t\tcontinue\n\t\t}\n\t\tchildren = append(children, dependent.Issue)\n\t}\n\n\tif len(children) == 0 {\n\t\troot, err := r.GetIssue(ctx, moleculeID)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"molecule %s not found: %w\", moleculeID, err)\n\t\t}\n\t\treturn &types.MoleculeLastActivity{\n\t\t\tMoleculeID:   moleculeID,\n\t\t\tLastActivity: root.UpdatedAt,\n\t\t\tSource:       \"molecule_updated\",\n\t\t}, nil\n\t}\n\n\tvar lastUpdatedAt time.Time\n\tvar lastUpdatedID string\n\tvar lastClosedAt time.Time\n\tvar lastClosedID string\n\thaveClosed := false\n\n\tfor _, child := range children {\n\t\tif child.UpdatedAt.After(lastUpdatedAt) {\n\t\t\tlastUpdatedAt = child.UpdatedAt\n\t\t\tlastUpdatedID = child.ID","sourceCodeStart":296,"sourceCodeEnd":332,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/cmd/bd/mol_port.go#L296-L332","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Run bd list or bd show <id> to confirm the molecule ID exists in the current database","Re-run from the correct repository/directory so the right .beads database is used","Check for typos or stale partial IDs; use the full ID copied from bd output","If the molecule was deleted, re-create it (bd mol pour or bd create) rather than querying its last activity"],"exampleFix":"// before: blind call\nlast, _ := reader.GetMoleculeLastActivity(ctx, \"bd-123\")\n// after: verify existence first\nif _, err := reader.GetIssue(ctx, \"bd-123\"); err != nil {\n\treturn fmt.Errorf(\"molecule bd-123 does not exist: %w\", err)\n}\nlast, err := reader.GetMoleculeLastActivity(ctx, \"bd-123\")","handlingStrategy":"validation","validationCode":"// confirm the molecule exists before computing last activity\nif _, err := reader.GetIssue(ctx, moleculeID); err != nil {\n\treturn fmt.Errorf(\"molecule %s does not exist here\", moleculeID)\n}","typeGuard":null,"tryCatchPattern":"last, err := reader.GetMoleculeLastActivity(ctx, molID)\nif err != nil && strings.Contains(err.Error(), \"not found\") {\n\t// fall back to listing molecules to pick a valid ID\n\treturn fmt.Errorf(\"unknown molecule %q; run `bd mol list`\", molID)\n}","preventionTips":["Copy molecule IDs from bd list/bd show output rather than typing them","Run commands from the repo whose .beads database holds the molecule","Confirm existence with bd show <id> before scripting against it","Avoid referencing deleted or gc'ed molecules; check bd mol list"],"tags":["go","not-found","molecule","cli"],"backgroundTag":"issue-not-found","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}