{"record":{"id":"5dd606e6deffc24d","repo":"gastownhall/beads","slug":"get-molecule-children-w","errorCode":null,"errorMessage":"get molecule children: %w","messagePattern":"get molecule children: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/bd/mol_port.go","lineNumber":300,"sourceCode":"\t\t}\n\t\tstats.Total++\n\t\tswitch dependent.Status {\n\t\tcase types.StatusClosed:\n\t\t\tstats.Completed++\n\t\tcase types.StatusInProgress:\n\t\t\tstats.InProgress++\n\t\t\tif stats.CurrentStepID == \"\" {\n\t\t\t\tstats.CurrentStepID = dependent.ID\n\t\t\t}\n\t\t}\n\t}\n\treturn stats, nil\n}\n\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,","sourceCodeStart":282,"sourceCodeEnd":318,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/cmd/bd/mol_port.go#L282-L318","documentation":"GetMoleculeLastActivity wraps any failure from GetDependentsWithMetadata (the query fetching a molecule's child issues) with the 'get molecule children' prefix. It indicates the storage/query layer failed while enumerating dependent issues for the molecule, before last-activity computation could start. The underlying cause is preserved via %w so callers can errors.Is/As it.","triggerScenarios":"Calling bd mol last-activity (runMolLastActivityProxiedServer) when the database query for dependents fails: storage driver errors, corrupt or locked Dolt database, context cancellation/timeouts, or an internal error in the dependents-with-metadata query.","commonSituations":"Running the command against a corrupted or unavailable .beads/Dolt database; a killed or mid-migration local DB; a stale database schema after a beads version upgrade; transient storage I/O failure.","solutions":["Inspect the wrapped cause (%w) with errors.Is/As or by reading the full error chain to find the storage-level failure","Verify the local database is healthy (run bd doctor / re-open the repo; check .beads storage)","Retry the command — transient locks or I/O failures often resolve on retry","If the schema is out of date after a beads upgrade, run the project's upgrade/migration path (bd upgrade/migrate) before retrying"],"exampleFix":"// before: only seeing 'get molecule children: ...'\nlast, err := reader.GetMoleculeLastActivity(ctx, molID)\n// after: unwrap and classify the root cause\nlast, err := reader.GetMoleculeLastActivity(ctx, molID)\nif err != nil {\n\tif errors.Is(err, sql.ErrConnDone) || errors.Is(err, context.DeadlineExceeded) {\n\t\tlast, err = reader.GetMoleculeLastActivity(ctx, molID) // retry transient\n\t}\n\treturn fmt.Errorf(\"last activity: %w\", err)\n}","handlingStrategy":"try-catch","validationCode":"// verify the molecule's dependents are queryable first\nif _, err := reader.GetDependentsWithMetadata(ctx, moleculeID); err != nil {\n\treturn fmt.Errorf(\"cannot read molecule %s: %w\", moleculeID, err)\n}","typeGuard":"func isStorageErr(err error) bool {\n\treturn err != nil && !errors.Is(err, sql.ErrNoRows) && !errors.Is(err, context.Canceled)\n}","tryCatchPattern":"last, err := reader.GetMoleculeLastActivity(ctx, molID)\nif err != nil {\n\tvar inner error\n\tif errors.As(err, &inner) && isTransientStorage(inner) {\n\t\t// retry once after backoff\n\t}\n\treturn err\n}","preventionTips":["Run bd doctor periodically to catch DB corruption early","Wrap long molecule queries in a context with a sane timeout instead of relying on cancellation","Keep the beads version and database schema in sync after upgrades","Inspect the full wrapped error chain (%w) before guessing at causes"],"tags":["go","storage","database","wrapped-error"],"backgroundTag":"database-query-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}