gastownhall/beads · error

record repo_id: %w

Error message

record repo_id: %w

What it means

During proxied-server init, bd seeds per-clone bookkeeping in a single transaction via recordProxiedInitTrackingState. This wrapper wraps a failure from cfg.SetMetadata(ctx, "repo_id", repoID) — the write of the repository fingerprint into shared metadata. The wrapped cause (database I/O, constraint, lock or connection error) is the real problem; this message just identifies which metadata write failed.

Source

Thrown at cmd/bd/init_proxied_server.go:371

}

// recordProxiedInitTrackingState seeds the per-clone bookkeeping: the
// repository and clone fingerprints, the synced-at marker and the recorded
// binary version.
//
// It is separate from the identity because its LIFETIME is: the identity is
// written once and then adopted forever, while these four describe the clone
// running init and are refreshed every time it runs. In the refusable one-time
// write, a re-init on a shared database would silently stop recording them.
func recordProxiedInitTrackingState(ctx context.Context, provider uow.UnitOfWorkProvider, repoID, cloneID string) error {
	return uow.RunTx(ctx, provider, func(ctx context.Context, uw uow.UnitOfWork) (string, error) {
		cfg := uw.ConfigUseCase()
		// An absent fingerprint is recorded as nothing rather than as "": an
		// empty row reads back to cross-project verification as a clone whose
		// fingerprint failed to compute.
		if repoID != "" {
			if err := cfg.SetMetadata(ctx, "repo_id", repoID); err != nil {
				return "", fmt.Errorf("record repo_id: %w", err)
			}
		}
		if cloneID != "" {
			if err := cfg.SetMetadata(ctx, "clone_id", cloneID); err != nil {
				return "", fmt.Errorf("record clone_id: %w", err)
			}
		}
		if err := cfg.SetMetadata(ctx, "last_import_time", time.Now().UTC().Format(time.RFC3339)); err != nil {
			return "", fmt.Errorf("record last_import_time: %w", err)
		}
		if err := cfg.SetLocalMetadata(ctx, workapi.MetadataKeyVersion, Version); err != nil {
			return "", fmt.Errorf("record bd_version: %w", err)
		}
		return "bd init", nil
	})
}

// configureProxiedInitDoltRemote adds the sync remote, skipping a name that is

View on GitHub (pinned to 71377f2769)

Solutions

  1. Check connectivity to the proxied Dolt server (bd doctor / server logs) and retry bd init
  2. Verify the database user has write access to the metadata/config tables in the shared database
  3. Inspect the wrapped cause (%w) in the full error output for the underlying driver error
  4. If the database is an older schema, run 'bts migrate' to heal it before re-running bd init

Example fix

// before (diagnosing)
err: "record repo_id: connection refused"
// after: ensure the team server is reachable, then re-run
bd doctor   # verify server reachability
bd init     # retry init once the server is up
Defensive patterns

Strategy: retry

Validate before calling

// pre-check: server reachable and db writable before init
if err := bdDoctorCheckServer(); err != nil {
    return fmt.Errorf("team server unreachable, fix before init: %w", err)
}

Try / catch

var perr *bd.InitError
if errors.As(err, &perr) && strings.Contains(perr.Error(), "record repo_id:") {
    // inspect wrapped cause, ensure server up, retry init
    fmt.Printf("metadata write failed: %v\n", errors.Unwrap(perr))
}

Prevention

When it happens

Trigger: bd init running in proxied-server (team-server) mode where the repo_id fingerprint is non-empty and SetMetadata on the config use case fails — e.g. the shared Dolt database is unavailable, read-only, or the transaction aborts.

Common situations: Shared team-server Dolt database briefly down or migrated; the connecting user lacks write privileges on the metadata table; connection dropped mid-init; repo_id computed for the first time on a re-init against an older database.

Related errors


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