{"record":{"id":"84b4a1f037e81372","repo":"gastownhall/beads","slug":"add-backup-s-w","errorCode":null,"errorMessage":"add backup %s: %w","messagePattern":"add backup (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/versioncontrolops/backup.go","lineNumber":13,"sourceCode":"package versioncontrolops\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\t\"path/filepath\"\n\t\"strings\"\n)\n\n// BackupAdd registers a Dolt backup destination.\nfunc BackupAdd(ctx context.Context, db DBConn, name, url string) error {\n\tif _, err := db.ExecContext(ctx, \"CALL DOLT_BACKUP('add', ?, ?)\", name, url); err != nil {\n\t\treturn fmt.Errorf(\"add backup %s: %w\", name, err)\n\t}\n\treturn nil\n}\n\n// BackupSync pushes the database to the named backup destination.\nfunc BackupSync(ctx context.Context, db DBConn, name string) error {\n\tif _, err := db.ExecContext(ctx, \"CALL DOLT_BACKUP('sync', ?)\", name); err != nil {\n\t\treturn fmt.Errorf(\"sync backup %s: %w\", name, err)\n\t}\n\treturn nil\n}\n\n// BackupRemove removes a configured Dolt backup destination.\nfunc BackupRemove(ctx context.Context, db DBConn, name string) error {\n\tif _, err := db.ExecContext(ctx, \"CALL DOLT_BACKUP('rm', ?)\", name); err != nil {\n\t\treturn fmt.Errorf(\"remove backup %s: %w\", name, err)\n\t}\n\treturn nil","sourceCodeStart":1,"sourceCodeEnd":31,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/storage/versioncontrolops/backup.go#L1-L31","documentation":"BackupAdd runs `CALL DOLT_BACKUP('add', ?, ?)` to register a named backup destination in Dolt and wraps any ExecContext failure as \"add backup <name>: <cause>\". The library throws it whenever the SQL procedure call itself fails — bad arguments, an invalid URL, or a database-level error. The wrapped error is the authoritative driver/Dolt message.","triggerScenarios":"BackupAdd(ctx, db, name, url) when db.ExecContext fails: invalid backup URL, Dolt rejecting the name/URL pair, connection error, or DOLT_BACKUP not supported by the server.","commonSituations":"Malformed file:// or remote URL passed to DirToFileURL or hand-built; calling against a non-Dolt connection or embedded driver without backup support; duplicate or reserved backup names; network unreachable for remote backups.","solutions":["Inspect the wrapped cause (%w) for the real Dolt error and fix the URL or name accordingly","Validate the URL scheme with DirToFileURL or url.Parse before calling BackupAdd","Confirm the connection is a Dolt database whose server version supports DOLT_BACKUP","Retry if the cause is a transient connection error"],"exampleFix":"// before\n_ = versioncontrolops.BackupAdd(ctx, db, \"offsite\", \"htp:/bad-url\")\n// after\nu, err := versioncontrolops.DirToFileURL(\"/backups/db\")\nif err != nil { return err }\nif err := versioncontrolops.BackupAdd(ctx, db, \"offsite\", u); err != nil {\n\treturn fmt.Errorf(\"register backup: %w\", err)\n}","handlingStrategy":"validation","validationCode":"func validateBackupURL(url string) error {\n\tu, err := url2.Parse(url)\n\tif err != nil || u.Scheme == \"\" { return fmt.Errorf(\"invalid backup url: %q\", url) }\n\treturn nil\n}\n// call validateBackupURL(u) before BackupAdd","typeGuard":null,"tryCatchPattern":"if err := vcops.BackupAdd(ctx, db, name, url); err != nil {\n\tvar derr *driverError // unwrap to inspect the %w cause\n\tif errors.Unwrap(err) != nil && strings.Contains(errors.Unwrap(err).Error(), \"unsupported\") {\n\t\treturn fmt.Errorf(\"DOLT_BACKUP unsupported by server: %w\", err)\n\t}\n\treturn err\n}","preventionTips":["Always build file:// URLs via DirToFileURL, never string concatenation","Validate URL scheme and name non-empty before calling","Confirm server supports DOLT_BACKUP once at startup"],"tags":["dolt","backup","sql","error-wrapping"],"backgroundTag":"dolt-backup-operation-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}