{"record":{"id":"62ddb0a6bf53cf29","repo":"gastownhall/beads","slug":"failed-to-find-backup-directory-w","errorCode":null,"errorMessage":"failed to find backup directory: %w","messagePattern":"failed to find backup directory: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/bd/backup_restore.go","lineNumber":54,"sourceCode":"\t\t\treturn HandleErrorRespectJSON(\"backup restore is not supported in proxied-server mode\")\n\t\t}\n\t\tevt := metrics.NewCommandEvent(\"backup-restore\")\n\t\tdefer func() {\n\t\t\tif c := metrics.Global(); c != nil {\n\t\t\t\tc.CloseEventAndAdd(evt)\n\t\t\t}\n\t\t}()\n\n\t\tctx := rootCtx\n\n\t\tvar dir string\n\t\tif len(args) > 0 {\n\t\t\tdir = args[0]\n\t\t} else {\n\t\t\tvar err error\n\t\t\tdir, err = backupDir()\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"failed to find backup directory: %w\", err)\n\t\t\t}\n\t\t}\n\n\t\tif err := validateBackupRestoreDir(dir); err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tforce, _ := cmd.Flags().GetBool(\"force\")\n\n\t\tif err := runBackupRestore(ctx, store, dir, force); err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tif !jsonOutput {\n\t\t\tfmt.Printf(\"%s Restore complete\\n\", ui.RenderPass(\"✓\"))\n\t\t}\n\n\t\treturn nil","sourceCodeStart":36,"sourceCodeEnd":72,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/cmd/bd/backup_restore.go#L36-L72","documentation":"In 'bd backup restore', when no directory argument is supplied, the tool resolves the default backup location via backupDir(). If that resolution fails (typically because no backup has been registered/added in this project's config), this wrapped error is returned and restore aborts before validating the directory.","triggerScenarios":"Running 'bd backup restore' with no positional dir argument while backupDir() cannot determine the backup directory — e.g. no backup destination has ever been added via 'bd backup add' or the beads config is missing/unreadable.","commonSituations":"New machine or fresh clone where backup config was never set up; typos or missing config.yaml in .beads; running restore before ever running 'bd backup'; BEADS_DIR pointing at a directory without backup configuration.","solutions":["Pass the backup directory explicitly: 'bd backup restore /path/to/backup'","Register a default backup location first with 'bd backup add <dest>'","Check .beads config for the backup destination entry and fix/remove a stale one","Create a backup first with 'bd backup' so a default directory exists"],"exampleFix":"// before\nbd backup restore\n// after\nbd backup restore ~/.beads-backups/myproject  # or: bd backup add <dest> first","handlingStrategy":"validation","validationCode":"if dir == \"\" {\n\tif _, err := os.Stat(defaultBackupDir()); err != nil {\n\t\treturn fmt.Errorf(\"no backup configured; run 'bd backup add <dest>' first\")\n\t}\n}","typeGuard":"dir != \"\" && os.Stat(dir) == nil","tryCatchPattern":"dir, err := backupDir()\nif err != nil {\n\treturn fmt.Errorf(\"failed to find backup directory: %w\\nTip: run 'bd backup add <dest>' or pass a directory argument\", err)\n}","preventionTips":["Always register a default with 'bd backup add <dest>' after bd init","Pass the backup directory explicitly in scripts instead of relying on defaults","Keep .beads config under version control or backed up so backup destinations survive machine changes","Verify with 'bd backup list'/config that a destination exists before scripting restores"],"tags":["backup","restore","config","go"],"backgroundTag":"backup-directory-unresolved","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}