{"record":{"id":"2ad77b0ae1f49fb3","repo":"gastownhall/beads","slug":"backfill-custom-types-w","errorCode":null,"errorMessage":"backfill custom_types: %w","messagePattern":"backfill custom_types: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/schema/backfill.go","lineNumber":17,"sourceCode":"package schema\n\nimport (\n\t\"context\"\n\t\"database/sql\"\n\t\"fmt\"\n\t\"log\"\n\t\"strings\"\n\n\t\"github.com/steveyegge/beads/internal/storage/issueops\"\n\t\"github.com/steveyegge/beads/internal/types\"\n)\n\nfunc ensureBackfilledCustomStatusesCustomTypes(ctx context.Context, db DBConn) (bool, error) {\n\ttypesWrote, err := backfillCustomTypes(ctx, db)\n\tif err != nil {\n\t\treturn typesWrote, fmt.Errorf(\"backfill custom_types: %w\", err)\n\t}\n\tstatusesWrote, err := backfillCustomStatuses(ctx, db)\n\tif err != nil {\n\t\treturn typesWrote || statusesWrote, fmt.Errorf(\"backfill custom_statuses: %w\", err)\n\t}\n\treturn typesWrote || statusesWrote, nil\n}\n\nfunc needsBackfilledCustomStatusesCustomTypes(ctx context.Context, db DBConn) (bool, error) {\n\ttypesNeed, err := needsCustomTypesBackfill(ctx, db)\n\tif err != nil {\n\t\treturn false, fmt.Errorf(\"custom_types: %w\", err)\n\t}\n\tstatusesNeed, err := needsCustomStatusesBackfill(ctx, db)\n\tif err != nil {\n\t\treturn false, fmt.Errorf(\"custom_statuses: %w\", err)\n\t}\n\treturn typesNeed || statusesNeed, nil","sourceCodeStart":1,"sourceCodeEnd":35,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/storage/schema/backfill.go#L1-L35","documentation":"Wrapper produced by ensureBackfilledCustomStatusesCustomTypes when backfillCustomTypes — which copies custom issue types from the config key 'types.custom' into the custom_types table — fails. The underlying error (SQL failure reading config/custom_types or inserting rows) is preserved via %w. MigrateUp calls this, so a database schema or config problem surfaces here during migration.","triggerScenarios":"backfillCustomTypes errors while running SELECT COUNT(*) FROM custom_types, reading config key 'types.custom', or INSERT IGNORE INTO custom_types — missing table, connection failure, or permission denial during MigrateUp.","commonSituations":"Fresh or partially migrated database where custom_types doesn't exist yet; DB user lacking SELECT/INSERT privileges; locked or corrupted Dolt database; connection dropped mid-migration.","solutions":["Run the full MigrateUp flow so numbered migrations create custom_types before the backfill runs.","Check the Dolt server is reachable and the database isn't locked; retry.","Verify the DB user has SELECT on config and custom_types plus INSERT on custom_types.","Inspect the wrapped driver error for the exact failing statement and fix accordingly (e.g. restore the config table)."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// Confirm prerequisite tables exist before MigrateUp's backfill stage\nfor _, t := range []string{\"custom_types\", \"config\"} {\n\tvar n int\n\tif err := db.QueryRowContext(ctx, `SELECT COUNT(*) FROM information_schema.TABLES WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = ?`, t).Scan(&n); err != nil || n == 0 {\n\t\treturn fmt.Errorf(\"table %s missing; migrations incomplete\", t)\n\t}\n}","typeGuard":null,"tryCatchPattern":"err := migrateUp(ctx)\nif err != nil && strings.Contains(err.Error(), \"backfill custom_types:\") {\n\tif isTransient(err) {\n\t\terr = migrateUp(ctx) // backfill is count-gated and idempotent\n\t}\n}","preventionTips":["Always run the full migration chain; never cherry-pick individual migration steps","Use a DB account with SELECT/INSERT on config and custom_types","Keep the Dolt server connection stable during upgrades","Back up the database before migrating"],"tags":["database","migration","backfill"],"backgroundTag":"schema-backfill-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}