{"record":{"id":"f0ad2c52ae587cfb","repo":"gastownhall/beads","slug":"checking-custom-types-w","errorCode":null,"errorMessage":"checking custom types: %w","messagePattern":"checking custom types: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/bd/cook.go","lineNumber":908,"sourceCode":"\t// Use labelHandler to extract labels for separate DB storage\n\tcollectSteps(f.Steps, protoID, idMapping, nil, &issues, &deps, func(issueID, label string) {\n\t\tlabels = append(labels, struct{ issueID, label string }{issueID, label})\n\t})\n\n\t// Collect dependencies from depends_on\n\tfor _, step := range f.Steps {\n\t\tcollectDependencies(step, idMapping, &deps)\n\t}\n\n\t// Create issues, labels, and dependencies in a single atomic transaction.\n\t// This prevents orphaned issues if label/dependency creation fails.\n\terr := transact(ctx, s, fmt.Sprintf(\"bd: cook formula %s\", protoID), func(tx storage.Transaction) error {\n\t\t// Flatten unregistered step types to task (with a warning) before\n\t\t// inserting, mirroring cloneSubgraphInto (pour). Without this,\n\t\t// PrepareIssueForInsert rejects them with \"invalid issue type\" and\n\t\t// the whole cook --persist transaction rolls back.\n\t\tif err := flattenUnregisteredIssueTypes(ctx, storeMolWriter{DoltStorage: s, tx: tx}, issues, deps); err != nil {\n\t\t\treturn fmt.Errorf(\"checking custom types: %w\", err)\n\t\t}\n\n\t\t// Create all issues\n\t\tif err := tx.CreateIssues(ctx, issues, actor); err != nil {\n\t\t\treturn fmt.Errorf(\"failed to create issues: %w\", err)\n\t\t}\n\n\t\t// Add labels\n\t\tfor _, l := range labels {\n\t\t\tif err := tx.AddLabel(ctx, l.issueID, l.label, actor); err != nil {\n\t\t\t\treturn fmt.Errorf(\"failed to add label %s to %s: %w\", l.label, l.issueID, err)\n\t\t\t}\n\t\t}\n\n\t\t// Add dependencies\n\t\tfor _, dep := range deps {\n\t\t\tif err := tx.AddDependency(ctx, dep, actor); err != nil {\n\t\t\t\treturn fmt.Errorf(\"failed to create dependency: %w\", err)","sourceCodeStart":890,"sourceCodeEnd":926,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/cmd/bd/cook.go#L890-L926","documentation":"Wraps failures from flattenUnregisteredIssueTypes inside the cook --persist transaction. That helper checks each generated step's issue type against registered custom types and flattens unregistered ones to `task`; if the check itself fails (e.g. it cannot read the configured issue types), the whole cook --persist transaction is rolled back under this message.","triggerScenarios":"cookFormula's transaction invokes flattenUnregisteredIssueTypes with storeMolWriter and the generated issues/deps; the helper errors when it cannot read registered issue types from config or fails validating/rewriting issue types on the generated issues.","commonSituations":"Corrupt or unreadable .beads/config listing issue types; custom type definitions removed while formulas still emit those step types; transaction/IO error reading config inside the Dolt transaction.","solutions":["Read the wrapped cause; if config read failed, repair or regenerate the .beads configuration defining issue types","Register the custom issue types your formula steps use (or rely on flattening to task) so the check passes","Verify database/config readability and permissions inside the transaction","Re-run `bd cook --persist` after fixing; the transaction is atomic so no partial data remains"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"err := transact(ctx, s, \"bd: cook formula \"+protoID, func(tx storage.Transaction) error {\n    if ferr := flattenUnregisteredIssueTypes(ctx, w, issues, deps); ferr != nil {\n        return fmt.Errorf(\"checking custom types: %w\", ferr)\n    }\n    return nil\n})\nif err != nil && strings.Contains(err.Error(), \"checking custom types\") {\n    log.Printf(\"type-flatten failed, transaction rolled back: %v\", errors.Unwrap(err))\n    // repair config/issue types, then re-run cook --persist\n}","preventionTips":["Keep the .beads config defining issue types readable and valid","Register custom types your formulas emit, or expect flattening to task","Run `bd doctor` if config reads start failing inside transactions","Treat cook --persist as atomic: a rollback means simply fix and re-run"],"tags":["transaction","issue-types","persist"],"backgroundTag":"invalid-issue-type","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}