{"record":{"id":"350b016fbce4dabe","repo":"gastownhall/beads","slug":"failed-to-check-parent-issue-w","errorCode":null,"errorMessage":"failed to check parent issue: %w","messagePattern":"failed to check parent issue: %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/bd/create_form.go","lineNumber":111,"sourceCode":"\t\tDependencies:       deps,\n\t}\n}\n\n// CreateIssueFromFormValues creates an issue from the given form values.\n// It returns the created issue and any error that occurred.\n// This function handles parent-child relationships, labels, dependencies,\n// and source_repo inheritance.\nfunc CreateIssueFromFormValues(ctx context.Context, s storage.DoltStorage, fv *createFormValues, actor string) (*types.Issue, error) {\n\t// If parent is specified, validate it exists and generate child ID\n\tvar explicitID string\n\tvar inheritedLabels []string\n\tif fv.ParentID != \"\" {\n\t\t_, err := s.GetIssue(ctx, fv.ParentID)\n\t\tif err != nil {\n\t\t\tif errors.Is(err, storage.ErrNotFound) {\n\t\t\t\treturn nil, fmt.Errorf(\"parent issue %s not found\", fv.ParentID)\n\t\t\t}\n\t\t\treturn nil, fmt.Errorf(\"failed to check parent issue: %w\", err)\n\t\t}\n\t\tchildID, err := s.GetNextChildID(ctx, fv.ParentID)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to generate child ID: %w\", err)\n\t\t}\n\t\texplicitID = childID\n\t\tctx = storage.WithReservedChildCounter(ctx, fv.ParentID, childID)\n\n\t\t// Inherit parent labels (GH#2100), matching bd create --parent behavior\n\t\tinheritedLabels, _ = s.GetLabels(ctx, fv.ParentID)\n\t}\n\n\tvar externalRefPtr *string\n\tif fv.ExternalRef != \"\" {\n\t\texternalRefPtr = &fv.ExternalRef\n\t}\n\n\tlabels := mergeCreateLabels(fv.Labels, inheritedLabels)","sourceCodeStart":93,"sourceCodeEnd":129,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/cmd/bd/create_form.go#L93-L129","documentation":"When CreateIssueFromFormValues checks the parent via s.GetIssue, any error that is NOT storage.ErrNotFound (network/driver failure, DB corruption, permission error) is wrapped as \"failed to check parent issue: %w\" so the underlying storage error is preserved. It distinguishes 'parent definitely missing' (308) from 'could not determine whether it exists'.","triggerScenarios":"Calling CreateIssueFromFormValues / runCreateForm with fv.ParentID set while the storage backend fails for a non-NotFound reason: Dolt driver connection errors, locked/corrupt DB, context cancellation mid-query.","commonSituations":"Embedded-mode or driver outages during form submit; running bd while another process holds the database in a bad state; transient storage failures in scripts that retry-able fix.","solutions":["Read the wrapped %w cause with `bd doctor` or by inspecting the full error output and fix the storage-layer issue first","Retry after confirming the database is healthy (`bd doctor`, `bd dolt pull`/status)","If the parent lookup keeps failing, create without a parent and attach later once storage recovers"],"exampleFix":"// before\n// opaque failure: fv.ParentID set, storage driver down\n// after\n// diagnose first, then create:\n//   bd doctor\n//   bd show <parent-id>   # confirm storage works\n//   bd create \"Task\" --parent <parent-id>","handlingStrategy":"try-catch","validationCode":"if err := exec.Command(\"bd\", \"doctor\").Run(); err != nil {\n    return fmt.Errorf(\"storage unhealthy; fix before creating child issues\")\n}","typeGuard":null,"tryCatchPattern":"err := runCreateForm(...)\nif err != nil {\n    var notFound bool\n    if strings.Contains(err.Error(), \"parent issue \") && strings.Contains(err.Error(), \"not found\") {\n        notFound = true // error 308 path\n    }\n    if strings.HasPrefix(err.Error(), \"failed to check parent issue:\") {\n        // storage-layer failure: log full cause, back off and retry\n        log.Printf(\"storage check failed: %v\", err)\n    }\n    _ = notFound\n}","preventionTips":["Run `bd doctor` before batch form-driven creates","Handle ErrNotFound separately from other storage errors in embedded usage","Retry transient driver failures with backoff; don't conflate them with missing parents"],"tags":["cli","storage","parent-child","wrapped-error"],"backgroundTag":"storage-check-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}