gastownhall/beads · warning
%s; %s
Error message
%s; %s
What it means
syncProjectIDFromDB aligns the project ID stored in the workspace config with the one read from the restored database. If reading the DB project ID fails or the workspace's beads directory cannot be located (FindBeadsDir returns ""), it combines the active-workspace error with a diagnostic hint via fmt.Errorf("%s; %s", ...). It signals the restored DB is fine but the local workspace config could not be updated.
Source
Thrown at cmd/bd/backup_restore.go:145
fmt.Fprintf(os.Stderr, "Warning: failed to register backup remote: %v\n", err)
return
}
if err := saveDoltBackupConfig(backupURL); err != nil {
fmt.Fprintf(os.Stderr, "Warning: backup registered but failed to save config: %v\n", err)
}
}
// syncProjectIDFromDB reads _project_id from the restored database and
// updates metadata.json to match, preventing identity mismatch errors.
func syncProjectIDFromDB(ctx context.Context, s storage.DoltStorage) error {
dbID, err := s.GetMetadata(ctx, "_project_id")
if err != nil || dbID == "" {
return err
}
beadsDir := beads.FindBeadsDir()
if beadsDir == "" {
return fmt.Errorf("%s; %s", activeWorkspaceNotFoundError(), diagHint())
}
cfg, err := configfile.Load(beadsDir)
if err != nil {
return err
}
if cfg.ProjectID == dbID {
return nil // already in sync
}
cfg.ProjectID = dbID
return cfg.Save(beadsDir)
}
func validateBackupRestoreDir(dir string) error {
if _, err := os.Stat(dir); os.IsNotExist(err) {
return fmt.Errorf("backup directory not found: %s\nRun 'bd backup' first to create a backup", dir)View on GitHub (pinned to 71377f2769)
Solutions
- Run the restore from within the project root containing .beads so FindBeadsDir resolves
- Run 'bd init' in the target directory to create the beads workspace
- Set BEADS_DIR (or the equivalent config) to point at the workspace explicitly
- Read the first %s segment of the message — it carries the activeWorkspaceNotFoundError cause
Example fix
// before bd backup restore /path/to/backup # run from ~/scratch (no .beads) // after cd /path/to/project # directory containing .beads bd backup restore /path/to/backup
Defensive patterns
Strategy: validation
Validate before calling
if beads.FindBeadsDir() == "" {
return fmt.Errorf("run this command inside a beads workspace (bd init) before syncing project ID")
} Type guard
beadsDir := beads.FindBeadsDir(); beadsDir != ""
Try / catch
if err := syncProjectIDFromDB(ctx, bs); err != nil {
if strings.Contains(err.Error(), "workspace") {
// cd to project root or bd init, then retry
}
return err
} Prevention
- Always execute restore/sync from the project root that contains .beads
- Set BEADS_DIR explicitly in CI to avoid workspace-detection ambiguity
- Run 'bd init' on any fresh target directory before restoring into it
- Treat this as a post-restore config step; verify cfg.ProjectID after restore
When it happens
Trigger: Called after a successful restore (and in tests). The beads directory lookup fails — running outside any beads workspace / no .beads found up the tree — while fetching the DB project ID also returned no usable value (dbID == "").
Common situations: Restoring into a scratch/temp directory that has no .beads; running the command from a subdirectory outside the project; BEADS_DIR env var unset and workspace detection failing; partially initialized workspace.
Related errors
- server: NewDoltServer: doltBinExec is required
- server: NewDoltServer: rootDir is required
- server: NewDoltServer: configPath is required
- %s
- %s; %s
AI-assisted analysis of gastownhall/beads@71377f2769 (2026-08-30).
Data as JSON: /api/errors/af6965cf03417051.
Report an issue: GitHub.