gastownhall/beads · error

db: RemoveRemote %s: %w

Error message

db: RemoveRemote %s: %w

What it means

This error is returned by RemoveRemote when the underlying version-control layer (r.vc.Remote with the 'remove' subcommand) fails to delete a named remote. It wraps the VC error with the remote name for context, meaning the remote still exists in dolt_remotes.

Source

Thrown at internal/storage/domain/db/remote.go:33

}

type remoteSQLRepositoryImpl struct {
	runner Runner
	vc     DoltVersionControlSQLRepository
}

var _ domain.RemoteSQLRepository = (*remoteSQLRepositoryImpl)(nil)

func (r *remoteSQLRepositoryImpl) AddRemote(ctx context.Context, name, url string) error {
	if err := r.vc.Remote(ctx, "add", name, url); err != nil {
		return fmt.Errorf("db: AddRemote %s: %w", name, err)
	}
	return nil
}

func (r *remoteSQLRepositoryImpl) RemoveRemote(ctx context.Context, name string) error {
	if err := r.vc.Remote(ctx, "remove", name); err != nil {
		return fmt.Errorf("db: RemoveRemote %s: %w", name, err)
	}
	return nil
}

func (r *remoteSQLRepositoryImpl) ListRemotes(ctx context.Context) ([]domain.Remote, error) {
	rows, err := r.runner.QueryContext(ctx, "SELECT name, url FROM dolt_remotes")
	if err != nil {
		return nil, fmt.Errorf("db: ListRemotes: query: %w", err)
	}
	defer rows.Close()

	var remotes []domain.Remote
	for rows.Next() {
		var rem domain.Remote
		if err := rows.Scan(&rem.Name, &rem.URL); err != nil {
			return nil, fmt.Errorf("db: ListRemotes: scan: %w", err)
		}
		remotes = append(remotes, rem)

View on GitHub (pinned to 71377f2769)

Solutions

  1. Read the wrapped cause after the remote name to see the VC error
  2. Confirm the remote exists with ListRemotes before removing; treat 'not found' as success for idempotent cleanup
  3. Check the exact remote name spelling/case
  4. Retry if the failure was a transient backend lock/conflict

Example fix

// before
if err := remotes.RemoveRemote(ctx, name); err != nil { return err }
// after
if err := remotes.RemoveRemote(ctx, name); err != nil {
    if strings.Contains(err.Error(), "not found") { return nil } // already removed
    return err
}
Defensive patterns

Strategy: try-catch

Validate before calling

remotes, err := store.ListRemotes(ctx)
if err != nil { return err }
found := false
for _, r := range remotes { if r.Name == name { found = true } }
if !found { return nil } // nothing to remove; treat as idempotent success

Type guard

func isRemoteNotFound(err error) bool {
    return err != nil && strings.Contains(err.Error(), "not found")
}

Try / catch

if err := store.RemoveRemote(ctx, name); err != nil {
    if strings.Contains(err.Error(), "not found") {
        return nil // already removed
    }
    return err
}

Prevention

When it happens

Trigger: Calling RemoveRemote(ctx, name) where the underlying `dolt remote remove` fails: remote name does not exist, name mismatch/case, or backend error while updating dolt_remotes.

Common situations: Trying to clean up a remote that was already deleted; misspelled remote name; concurrent modification of the remotes table; removing a remote during an active sync that holds a reference.

Related errors


AI-assisted analysis of gastownhall/beads@71377f2769 (2026-08-30). Data as JSON: /api/errors/142f23bd5ba35b42. Report an issue: GitHub.