{"record":{"id":"4033594b67a25aba","repo":"gastownhall/beads","slug":"inserting-status-q-w","errorCode":null,"errorMessage":"inserting status %q: %w","messagePattern":"inserting status %q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/schema/backfill.go","lineNumber":151,"sourceCode":"\t\treturn false, nil\n\t}\n\tif err != nil {\n\t\treturn false, err\n\t}\n\tif value == \"\" {\n\t\treturn false, nil\n\t}\n\n\tparsed, parseErr := types.ParseCustomStatusConfig(value)\n\tif parseErr != nil {\n\t\tlog.Printf(\"schema: skipping invalid status.custom entries: %v\", parseErr)\n\t\treturn false, nil\n\t}\n\twrote := false\n\tfor _, s := range parsed {\n\t\tres, err := db.ExecContext(ctx, \"INSERT IGNORE INTO custom_statuses (name, category) VALUES (?, ?)\", s.Name, string(s.Category))\n\t\tif err != nil {\n\t\t\treturn wrote, fmt.Errorf(\"inserting status %q: %w\", s.Name, err)\n\t\t}\n\t\tif n, err := res.RowsAffected(); err == nil && n > 0 {\n\t\t\twrote = true\n\t\t}\n\t}\n\treturn wrote, nil\n}\n","sourceCodeStart":133,"sourceCodeEnd":159,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/storage/schema/backfill.go#L133-L159","documentation":"This error wraps a failed INSERT IGNORE INTO custom_statuses (name, category) while seeding custom statuses from configuration during migration. Since INSERT IGNORE absorbs duplicates, the wrapped cause is a genuine SQL failure such as a missing table, denied privilege, connection loss, or cancellation. Raised by backfillCustomStatuses during MigrateUp.","triggerScenarios":"The per-status INSERT IGNORE in backfillCustomStatuses returns a driver error: custom_statuses table absent (migrations not run), INSERT privilege denied, context cancelled, or connection dropped mid-loop.","commonSituations":"Partially migrated database; restricted DB user; Dolt server restart during upgrade; custom_statuses locked by another session.","solutions":["Run the complete migration flow so custom_statuses is created, then retry MigrateUp.","Grant the DB user INSERT on custom_statuses.","Re-establish Dolt connectivity and re-run; the backfill is count-gated and safe to repeat.","Inspect the wrapped driver error to identify the exact failing statement."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// Confirm custom_statuses exists and is writable before backfill\nvar n int\nif err := db.QueryRowContext(ctx, `SELECT COUNT(*) FROM information_schema.TABLES WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'custom_statuses'`).Scan(&n); err != nil || n == 0 {\n\treturn fmt.Errorf(\"custom_statuses missing; run migrations\")\n}\n// privilege probe (harmless insert rolled back in a txn)\ntx, _ := db.BeginTx(ctx, nil)\n_, err := tx.ExecContext(ctx, \"INSERT IGNORE INTO custom_statuses (name, category) VALUES ('__probe__','open')\")\ntx.Rollback()","typeGuard":null,"tryCatchPattern":"err := migrateUp(ctx)\nif err != nil && strings.Contains(err.Error(), \"inserting status \") {\n\tif isTransient(err) {\n\t\terr = migrateUp(ctx)\n\t}\n}","preventionTips":["Run migrations fully before dependent commands","Grant INSERT on custom_statuses to the DB user","Avoid interrupting MigrateUp mid-backfill","Verify custom-status config values are well-formed before upgrading"],"tags":["database","backfill","sql"],"backgroundTag":"schema-backfill-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}