{"record":{"id":"a0f0170ac339b7b3","repo":"gastownhall/beads","slug":"record-repo-id-w","errorCode":null,"errorMessage":"record repo_id: %w","messagePattern":"record repo_id: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/bd/init_proxied_server.go","lineNumber":371,"sourceCode":"}\n\n// recordProxiedInitTrackingState seeds the per-clone bookkeeping: the\n// repository and clone fingerprints, the synced-at marker and the recorded\n// binary version.\n//\n// It is separate from the identity because its LIFETIME is: the identity is\n// written once and then adopted forever, while these four describe the clone\n// running init and are refreshed every time it runs. In the refusable one-time\n// write, a re-init on a shared database would silently stop recording them.\nfunc recordProxiedInitTrackingState(ctx context.Context, provider uow.UnitOfWorkProvider, repoID, cloneID string) error {\n\treturn uow.RunTx(ctx, provider, func(ctx context.Context, uw uow.UnitOfWork) (string, error) {\n\t\tcfg := uw.ConfigUseCase()\n\t\t// An absent fingerprint is recorded as nothing rather than as \"\": an\n\t\t// empty row reads back to cross-project verification as a clone whose\n\t\t// fingerprint failed to compute.\n\t\tif repoID != \"\" {\n\t\t\tif err := cfg.SetMetadata(ctx, \"repo_id\", repoID); err != nil {\n\t\t\t\treturn \"\", fmt.Errorf(\"record repo_id: %w\", err)\n\t\t\t}\n\t\t}\n\t\tif cloneID != \"\" {\n\t\t\tif err := cfg.SetMetadata(ctx, \"clone_id\", cloneID); err != nil {\n\t\t\t\treturn \"\", fmt.Errorf(\"record clone_id: %w\", err)\n\t\t\t}\n\t\t}\n\t\tif err := cfg.SetMetadata(ctx, \"last_import_time\", time.Now().UTC().Format(time.RFC3339)); err != nil {\n\t\t\treturn \"\", fmt.Errorf(\"record last_import_time: %w\", err)\n\t\t}\n\t\tif err := cfg.SetLocalMetadata(ctx, workapi.MetadataKeyVersion, Version); err != nil {\n\t\t\treturn \"\", fmt.Errorf(\"record bd_version: %w\", err)\n\t\t}\n\t\treturn \"bd init\", nil\n\t})\n}\n\n// configureProxiedInitDoltRemote adds the sync remote, skipping a name that is","sourceCodeStart":353,"sourceCodeEnd":389,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/cmd/bd/init_proxied_server.go#L353-L389","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Check connectivity to the proxied Dolt server (bd doctor / server logs) and retry bd init","Verify the database user has write access to the metadata/config tables in the shared database","Inspect the wrapped cause (%w) in the full error output for the underlying driver error","If the database is an older schema, run 'bts migrate' to heal it before re-running bd init"],"exampleFix":"// before (diagnosing)\nerr: \"record repo_id: connection refused\"\n// after: ensure the team server is reachable, then re-run\nbd doctor   # verify server reachability\nbd init     # retry init once the server is up","handlingStrategy":"retry","validationCode":"// pre-check: server reachable and db writable before init\nif err := bdDoctorCheckServer(); err != nil {\n    return fmt.Errorf(\"team server unreachable, fix before init: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"var perr *bd.InitError\nif errors.As(err, &perr) && strings.Contains(perr.Error(), \"record repo_id:\") {\n    // inspect wrapped cause, ensure server up, retry init\n    fmt.Printf(\"metadata write failed: %v\\n\", errors.Unwrap(perr))\n}","preventionTips":["Run bd doctor before init to confirm team-server reachability","Ensure the database user has write grants on shared metadata","Avoid re-pointing bd at legacy databases without 'bts migrate'","Retry init on transient network failures — the tracking write is transactional"],"tags":["init","metadata","dolt","team-server","persistence"],"backgroundTag":"metadata-write-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}