{"record":{"id":"70ebd9abf88d1db3","repo":"gastownhall/beads","slug":"failed-to-update-external-ref-for-s-v","errorCode":null,"errorMessage":"Failed to update external_ref for %s: %v","messagePattern":"Failed to update external_ref for (.+?): (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"internal/tracker/engine.go","lineNumber":1094,"sourceCode":"\t\t\tcreated, err := e.Tracker.CreateIssue(ctx, pushIssue)\n\t\t\tif err != nil {\n\t\t\t\tif isRateLimitExhausted(err) {\n\t\t\t\t\treturn stats, fmt.Errorf(\"sync aborted: %w\", err)\n\t\t\t\t}\n\t\t\t\te.warn(\"Failed to create %s in %s: %v\", issue.ID, e.Tracker.DisplayName(), err)\n\t\t\t\tstats.Errors++\n\t\t\t\tif isRateLimitedErr(err) {\n\t\t\t\t\te.warnRateLimitAbort(err, len(issues)-stats.Created-stats.Updated-stats.Skipped-stats.Errors)\n\t\t\t\t\treturn stats, nil\n\t\t\t\t}\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\t// Update local issue with external ref\n\t\t\tref := e.Tracker.BuildExternalRef(created)\n\t\t\tupdates := map[string]interface{}{\"external_ref\": ref}\n\t\t\tif err := e.Store.UpdateIssue(ctx, issue.ID, updates, e.Actor); err != nil {\n\t\t\t\te.warn(\"Failed to update external_ref for %s: %v\", issue.ID, err)\n\t\t\t\tstats.Errors++\n\t\t\t\t// Note: issue WAS created externally, so we still count Created\n\t\t\t\t// but also flag the error so the user knows the link is broken\n\t\t\t}\n\t\t\t// Surface any partial-success warnings from the create (e.g. a\n\t\t\t// follow-up state change that failed) through the sync result so a\n\t\t\t// degraded push is visible rather than silently swallowed.\n\t\t\tfor _, w := range created.Warnings {\n\t\t\t\te.warn(\"%s (%s)\", w, issue.ID)\n\t\t\t}\n\t\t\t// Remember what we just pushed so the next sync can skip the fetch.\n\t\t\te.recordPushHash(ctx, issue, ref)\n\t\t\tstats.Created++\n\t\t} else if !opts.CreateOnly || forceIDs[issue.ID] {\n\t\t\t// Update existing external issue\n\t\t\textID := e.Tracker.ExtractIdentifier(extRef)\n\t\t\tif extID == \"\" {\n\t\t\t\tstats.Skipped++","sourceCodeStart":1076,"sourceCodeEnd":1112,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/tracker/engine.go#L1076-L1112","documentation":"During a non-batch push, bd created the issue in the external tracker successfully but then failed to write the resulting external_ref back to the local store via Store.UpdateIssue. The remote issue exists but the local record is not linked to it, so the next sync would attempt to create a duplicate. This is a warning-level message counted as a sync error; the issue is still counted as Created because the external side succeeded.","triggerScenarios":"e.Store.UpdateIssue(ctx, issue.ID, {external_ref: ref}, e.Actor) returns an error right after a successful Tracker.CreateIssue — e.g. local DB lock, closed DB, storage driver failure, or a read-only database.","commonSituations":"Local database locked by another bd process during sync; disk-full or corrupted Dolt/SQLite store; running sync while a migration or compaction holds a write lock; stale database connection after a long-running push.","solutions":["Check the underlying storage error in the warning text (e.g. 'database is locked') and resolve the local DB issue (kill competing bd processes, wait for locks).","Re-run `bd sync` or `bd push`; on the next pass the issue has no external_ref yet, so re-link or re-create will be attempted.","Verify DB integrity with the storage backend's check tool (e.g. Dolt fsck / SQLite integrity_check) if errors persist.","If duplicates appear, remove the duplicate external issue and fix the external_ref manually via `bd update`.","Back up and repair the local store (.beads directory) if corruption is suspected."],"exampleFix":"// before (shell): repeated lock errors during concurrent use\nbd sync &\nbd push &\n// after: serialize write operations\nbd sync\nbd push","handlingStrategy":"retry","validationCode":"// before sync: confirm the local store is writable and not locked\nif _, err := os.Stat(\".beads\"); err != nil {\n    log.Fatalf(\"no .beads store: %v\", err)\n}\nout, _ := exec.Command(\"pgrep\", \"bd\").Output()\nif len(strings.TrimSpace(string(out))) > 0 { log.Println(\"another bd process may hold the write lock\") }","typeGuard":null,"tryCatchPattern":"// re-run sync when stats.Errors > 0 to relink missing external_refs\nstats, err := engine.Sync(ctx, opts)\nif err == nil && stats.Errors > 0 {\n    time.Sleep(2 * time.Second)\n    engine.Sync(ctx, opts)\n}","preventionTips":["Avoid concurrent bd write commands in the same repo","Check disk space before long-running syncs","Verify external_ref was persisted after push (bd show)","Run bd doctor if storage errors recur"],"tags":["sync","storage","external-ref","database-lock"],"backgroundTag":"external-ref-write-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}