{"record":{"id":"1dea9c05cd710101","repo":"gastownhall/beads","slug":"register-backup-remote-w-1dea9c","errorCode":null,"errorMessage":"register backup remote: %w","messagePattern":"register backup remote: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/embeddeddolt/version_control.go","lineNumber":759,"sourceCode":"\tif err != nil {\n\t\treturn err\n\t}\n\tbackupName := \"backup_export\"\n\n\treturn s.withMutatingDBConn(ctx, func(db versioncontrolops.DBConn) error {\n\t\t// Register as a backup remote (idempotent — remove first if exists).\n\t\t_ = versioncontrolops.BackupRemove(ctx, db, backupName)\n\t\tif err := versioncontrolops.BackupAdd(ctx, db, backupName, backupURL); err != nil {\n\t\t\t// Another backup (e.g. \"default\" registered by `bd backup init`) may\n\t\t\t// already point to this URL. In that case, sync using the existing\n\t\t\t// remote name rather than failing.\n\t\t\tif conflict := versioncontrolops.ExtractAddressConflictName(err); conflict != \"\" {\n\t\t\t\tif syncErr := versioncontrolops.BackupSync(ctx, db, conflict); syncErr != nil {\n\t\t\t\t\treturn fmt.Errorf(\"sync to backup: %w\", syncErr)\n\t\t\t\t}\n\t\t\t\treturn nil\n\t\t\t}\n\t\t\treturn fmt.Errorf(\"register backup remote: %w\", err)\n\t\t}\n\t\tif err := versioncontrolops.BackupSync(ctx, db, backupName); err != nil {\n\t\t\treturn fmt.Errorf(\"sync to backup: %w\", err)\n\t\t}\n\t\treturn nil\n\t})\n}\n\n// RestoreDatabase restores the database from a Dolt backup at dir.\n// The dir must exist locally and contain a valid Dolt backup.\n// When force is true, an existing database is overwritten.\nfunc (s *EmbeddedDoltStore) RestoreDatabase(ctx context.Context, dir string, force bool) error {\n\tinfo, err := os.Stat(dir)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"backup source does not exist: %w\", err)\n\t}\n\tif !info.IsDir() {\n\t\treturn fmt.Errorf(\"backup source is not a directory: %s\", dir)","sourceCodeStart":741,"sourceCodeEnd":777,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/storage/embeddeddolt/version_control.go#L741-L777","documentation":"Returned when registering the file:// backup remote via BackupAdd fails and the error is not an address conflict that can be worked around. This is the hard-failure path of remote registration in BackupDatabase.","triggerScenarios":"BackupDatabase calls BackupAdd(ctx, db, backupName, backupURL) with a malformed URL (DirToFileURL edge case), an invalid remote name, or a Dolt-level registration error not matching ExtractAddressConflictName.","commonSituations":"Backup dir path with characters that break file:// URL formation; Dolt refusing to add a remote with a duplicate name pointing at a DIFFERENT URL; database in a state preventing remote registration.","solutions":["Check the wrapped BackupAdd error for the Dolt root cause","Ensure the backup directory path is absolute, exists, and is a plain directory","If a remote with the same name exists at another URL, remove it (dolt backup remove / bd equivalent) and retry","Verify Dolt version compatibility for backup remote operations"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// ensure a clean absolute directory path before registering\nabs, err := filepath.Abs(dir)\nif err != nil { return err }\nif info, err := os.Stat(abs); err != nil || !info.IsDir() {\n    return fmt.Errorf(\"%%s must be an existing directory\", abs)\n}","typeGuard":null,"tryCatchPattern":"if err := store.BackupDatabase(ctx, dir); err != nil {\n    if strings.Contains(err.Error(), \"register backup remote\") { /* inspect existing remotes, remove stale ones, retry */ }\n}","preventionTips":["Use simple absolute directory paths without odd characters","Keep backup remote names unique per URL","Remove stale remotes before re-registering"],"tags":["go","dolt","backup","remote"],"backgroundTag":"remote-registration-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}