{"record":{"id":"d1b7133bd9ede86b","repo":"gastownhall/beads","slug":"failed-to-get-molecule-children-w","errorCode":null,"errorMessage":"failed to get molecule children: %w","messagePattern":"failed to get molecule children: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/bd/mol_port.go","lineNumber":276,"sourceCode":"\nfunc (r uowMolReader) GetCustomStatusesDetailed(ctx context.Context) ([]types.CustomStatus, error) {\n\treturn r.uw.ConfigUseCase().GetCustomStatuses(ctx)\n}\n\nfunc (r uowMolReader) GetMoleculeProgress(ctx context.Context, moleculeID string) (*types.MoleculeProgressStats, error) {\n\tstats := &types.MoleculeProgressStats{MoleculeID: moleculeID}\n\n\troot, err := r.GetIssue(ctx, moleculeID)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to get molecule: %w\", err)\n\t}\n\tif root != nil {\n\t\tstats.MoleculeTitle = root.Title\n\t}\n\n\tdependents, err := r.GetDependentsWithMetadata(ctx, moleculeID)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to get molecule children: %w\", err)\n\t}\n\n\tfor _, dependent := range dependents {\n\t\tif dependent.DependencyType != types.DepParentChild {\n\t\t\tcontinue\n\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","sourceCodeStart":258,"sourceCodeEnd":294,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/cmd/bd/mol_port.go#L258-L294","documentation":"After loading the root, `GetMoleculeProgress` fetches the molecule's children via `GetDependentsWithMetadata`. If that dependent-lookup fails, the error is wrapped as `failed to get molecule children: %w`, indicating the molecule root was fine but enumerating its child dependencies failed.","triggerScenarios":"`runMolCurrentProxiedServer` or `runMolProgressProxiedServer` requests progress for a molecule whose root resolves but whose dependents query errors out — dependency-table read failures, storage errors, or transaction issues inside `GetDependentsWithMetadata`, wrapped at the `fmt.Errorf(\"failed to get molecule children: %w\", err)` line.","commonSituations":"Corrupted or partially-synced dependency tables; database lock/IO errors under concurrent writes; a very large molecule hitting query timeouts; schema drift after a version upgrade.","solutions":["Unwrap the error and address the underlying dependent-query failure (storage health, locks).","Run `bd doctor` and, if needed, re-sync (`bd dolt pull`) to repair dependency data.","Retry the command — transient lock contention during concurrent writes commonly causes this."],"exampleFix":"// before\nstats, err := reader.GetMoleculeProgress(ctx, molID) // opaque child failure\n// after\nstats, err := reader.GetMoleculeProgress(ctx, molID)\nif err != nil {\n    log.Printf(\"children query failed: %v\", errors.Unwrap(err))\n}","handlingStrategy":"retry","validationCode":"// pre-check dependency data integrity\nbd doctor --json | jq -e '.healthy' >/dev/null || exit 1\nbd mol progress \"$MOL_ID\" --json >/dev/null 2>&1 || { echo \"children query failing; resync?\"; bd dolt pull; }","typeGuard":null,"tryCatchPattern":"var stats *types.MoleculeProgressStats\nvar err error\nfor i := 0; i < 3; i++ {\n\tstats, err = reader.GetMoleculeProgress(ctx, molID)\n\tif err == nil || !strings.Contains(err.Error(), \"molecule children\") {\n\t\tbreak\n\t}\n\ttime.Sleep(time.Duration(1<<i) * 100 * time.Millisecond) // transient lock retry\n}","preventionTips":["Avoid heavy concurrent writes while reading molecule progress.","Run `bd doctor` / resync after abnormal shutdowns to keep dependency tables consistent.","Bound retries and surface the unwrapped cause if failures persist."],"tags":["cli","dependencies","storage"],"backgroundTag":"dependency-query-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}