gastownhall/beads · warning

Failed to re-import %s: %v

Error message

Failed to re-import %s: %v

What it means

During conflict resolution with re-import (external wins), the engine failed to fetch the external version of the conflicted issue via Tracker.FetchIssue. The local issue keeps its current state and the external changes are not applied. Note the warning also fires when the fetch succeeds but returns nil (issue not found).

Source

Thrown at internal/tracker/engine.go:1285

			if c.LocalUpdated.After(c.ExternalUpdated) {
				forceIDs[c.IssueID] = true
				e.msg("Conflict on %s: local is newer, pushing", c.IssueID)
			} else {
				skipIDs[c.IssueID] = true
				allowPullOverwriteIDs[c.IssueID] = true
				e.msg("Conflict on %s: external is newer, importing", c.IssueID)
			}
		}
	}
}

// reimportIssue fetches an external version and reapplies its scalar fields.
// It deliberately preserves local labels because conflict reimport has no
// authoritative label collection to synchronize.
func (e *Engine) reimportIssue(ctx context.Context, c Conflict) {
	extIssue, err := e.Tracker.FetchIssue(ctx, c.ExternalIdentifier)
	if err != nil || extIssue == nil {
		e.warn("Failed to re-import %s: %v", c.IssueID, err)
		return
	}

	conv := e.Tracker.FieldMapper().IssueToBeads(extIssue)
	if conv == nil || conv.Issue == nil {
		return
	}

	updates := map[string]interface{}{
		"title":       conv.Issue.Title,
		"description": conv.Issue.Description,
		"priority":    conv.Issue.Priority,
		"status":      string(conv.Issue.Status),
	}
	if extIssue.Metadata != nil {
		if raw, err := json.Marshal(extIssue.Metadata); err == nil {
			updates["metadata"] = json.RawMessage(raw)
		}

View on GitHub (pinned to 71377f2769)

Solutions

  1. Check the wrapped error: 404 means the remote issue is gone — decide whether to delete locally or re-create remotely.
  2. Fix network/auth issues and re-run `bd sync`; conflicts will be recomputed.
  3. Verify the external_ref format is valid for the configured tracker.
  4. If the remote was deleted intentionally, delete the local issue (`bd delete <id>`).
  5. Retry later on transient 5xx/rate-limit responses.

Example fix

// before: remote issue deleted, reimport keeps failing
// decision: keep local copy without the stale link
bd update bd-42 --external-ref=""
bd sync
Defensive patterns

Strategy: retry

Validate before calling

// verify the external identifier is fetchable before conflict reimport
if _, err := tracker.FetchIssue(ctx, c.ExternalIdentifier); err != nil {
    log.Printf("pre-check failed for %s: %v", c.IssueID, err)
}

Try / catch

// retry network-shaped failures before giving up on reimport
for i := 0; i < 3; i++ {
    stats, err := engine.Sync(ctx, opts)
    if err == nil { break }
    if isNetErr(err) || isRateLimitedErr(err) { time.Sleep(backoff(i)); continue }
    break
}

Prevention

When it happens

Trigger: e.Tracker.FetchIssue(ctx, c.ExternalIdentifier) returns an error or a nil issue while reimporting a conflict — network failure, 404 for a deleted remote issue, invalid external identifier, or API auth failure.

Common situations: Remote issue deleted while a local edit was in flight; network outage or DNS failure during sync; external_ref points at an issue in a project the token can't read; tracker API temporarily down (5xx).

Related errors


AI-assisted analysis of gastownhall/beads@71377f2769 (2026-08-30). Data as JSON: /api/errors/555aed7e249fce0e. Report an issue: GitHub.