{"record":{"id":"5ba85b5311faf0c7","repo":"gastownhall/beads","slug":"failed-to-create-issue-w","errorCode":null,"errorMessage":"failed to create issue: %w","messagePattern":"failed to create issue: %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/bd/create_form.go","lineNumber":193,"sourceCode":"\t\t} else {\n\t\t\tdepType = types.DepBlocks\n\t\t\tdependsOnID = depSpec\n\t\t}\n\n\t\tif !depType.IsValid() {\n\t\t\tfmt.Fprintf(os.Stderr, \"Warning: invalid dependency type '%s' (valid: blocks, related, parent-child, discovered-from)\\n\", depType)\n\t\t\tcontinue\n\t\t}\n\n\t\tdepSpecs = append(depSpecs, domain.DependencySpec{Type: depType, TargetID: dependsOnID})\n\t}\n\n\t// The issue and its edges (parent-child per GH#1983, plus form deps)\n\t// commit in one transaction; a failed edge rolls back the create instead\n\t// of leaving a dep-less issue behind (same contract as bd create).\n\tedges := createDepEdges{parentID: fv.ParentID, specs: depSpecs}\n\tif err := createIssueWithDeps(ctx, s, issue, actor, edges); err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to create issue: %w\", err)\n\t}\n\n\tif edges.empty() {\n\t\t// Bare create: preserve the embedded-mode follow-up Dolt commit.\n\t\t// The deps path commits inside its transaction instead.\n\t\tshouldCommit, err := shouldCommitCreatePostWrites(issue, false)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"dolt auto-commit: %w\", err)\n\t\t}\n\t\tif shouldCommit {\n\t\t\tcommitMsg := fmt.Sprintf(\"bd: create %s\", issue.ID)\n\t\t\tif err := s.Commit(ctx, commitMsg); err != nil && !isDoltNothingToCommit(err) {\n\t\t\t\tWarnError(\"failed to commit post-create metadata: %v\", err)\n\t\t\t}\n\t\t}\n\t}\n\n\treturn issue, nil","sourceCodeStart":175,"sourceCodeEnd":211,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/cmd/bd/create_form.go#L175-L211","documentation":"Wraps a failure from createIssueWithDeps, which creates the issue and its edges (parent-child, form deps) in one transaction. If any edge write fails the whole create rolls back, so the issue was NOT created. The wrapped error names the failing edge or write.","triggerScenarios":"CreateIssueFromFormValues calls createIssueWithDeps with non-empty edges (parentID or depSpecs) and the transaction fails: duplicate ID collision, invalid dep target, or storage write error.","commonSituations":"Form references a dep target ID that doesn't exist; concurrent create claiming the same ID; Dolt transaction failure mid-write.","solutions":["Check the wrapped error for which dep/edge failed","Verify all dep target IDs exist (`bd show <id>` for each)","Retry — collision preflight is not airtight across processes","Create without deps first, then add deps with `bd dep add`"],"exampleFix":"// before (form references nonexistent dep)\n{\"deps\":[{\"target\":\"bd-9999\",\"type\":\"blocks\"}]}\n// after: use an existing ID\n{\"deps\":[{\"target\":\"bd-42\",\"type\":\"blocks\"}]}","handlingStrategy":"validation","validationCode":"for _, d := range depSpecs {\n    if _, err := findIssue(d.Target); err != nil {\n        return fmt.Errorf(\"dep target %s does not exist\", d.Target)\n    }\n}","typeGuard":null,"tryCatchPattern":"issue, err := CreateIssueFromFormValues(ctx, fv)\nif err != nil {\n    var target ErrDepMissing\n    if errors.As(err, &target) { /* fix or drop the dep and retry */ }\n    return err // issue was NOT created; do not assume it exists\n}","preventionTips":["Confirm all dep target IDs exist before submitting the form","Assume the create rolled back on this error — never assume a partial issue","Retry after resolving collisions instead of changing IDs blindly"],"tags":["transaction","dependencies","create","rollback"],"backgroundTag":"transactional-create-rolled-back","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}