gastownhall/beads · error
remove remote %s: %w
Error message
remove remote %s: %w
What it means
RemoveRemote removes a configured Dolt remote by executing CALL DOLT_REMOTE('remove', ?). This error wraps any failure of that stored-procedure call — the most common being that the named remote does not exist, or the Dolt engine rejected/failed the removal. The remote name is embedded in the message to identify which removal failed.
Source
Thrown at internal/storage/versioncontrolops/remotes.go:32
return nil, fmt.Errorf("list remotes: %w", err)
}
defer rows.Close()
var remotes []storage.RemoteInfo
for rows.Next() {
var r storage.RemoteInfo
if err := rows.Scan(&r.Name, &r.URL); err != nil {
return nil, fmt.Errorf("scan remote: %w", err)
}
remotes = append(remotes, r)
}
return remotes, rows.Err()
}
// RemoveRemote removes a configured Dolt remote.
func RemoveRemote(ctx context.Context, db DBConn, name string) error {
if _, err := db.ExecContext(ctx, "CALL DOLT_REMOTE('remove', ?)", name); err != nil {
return fmt.Errorf("remove remote %s: %w", name, err)
}
return nil
}
// Fetch fetches refs from a remote without merging.
//
// If user is non-empty, authenticates with that user — DOLT_REMOTE_PASSWORD
// must be set in the in-process Dolt server's environment.
//
// A failed DOLT_FETCH can leave orphaned tmp_pack_* files in the
// git-remote-cache; the embedded store's connection teardown sweeps those
// (cleanGitRemoteCacheGarbage). Do NOT run DOLT_GC here: dolt_gc invalidates
// every other open session on the same engine, so a failed fetch would break
// concurrent in-flight connections (bd-6dnrw.10).
func Fetch(ctx context.Context, db DBConn, peer, user string) error {
err := withRemoteEnvGuards(func() error {
if user != "" {
_, err := db.ExecContext(ctx, "CALL DOLT_FETCH('--user', ?, ?)", user, peer)View on GitHub (pinned to 71377f2769)
Solutions
- Call ListRemotes first and confirm the remote name exists (exact match, case-sensitive)
- Fix the remote name typo or skip removal if it is already absent
- Verify the DB connection is alive and points at the right database
- Inspect the wrapped error for the Dolt-level message (e.g. unknown remote vs connection refused)
Example fix
// before
if err := versioncontrolops.RemoveRemote(ctx, db, "origin"); err != nil {
return err
}
// after
remotes, _ := versioncontrolops.ListRemotes(ctx, db)
exists := false
for _, r := range remotes {
if r.Name == "origin" {
exists = true
}
}
if exists {
if err := versioncontrolops.RemoveRemote(ctx, db, "origin"); err != nil {
return fmt.Errorf("remove remote origin: %w", err)
}
} Defensive patterns
Strategy: validation
Validate before calling
remotes, err := versioncontrolops.ListRemotes(ctx, db)
if err != nil {
return err
}
found := false
for _, r := range remotes {
if r.Name == name {
found = true
}
}
if !found {
return nil // already absent; nothing to remove
} Type guard
func remoteExists(remotes []storage.RemoteInfo, name string) bool {
for _, r := range remotes {
if r.Name == name {
return true
}
}
return false
} Try / catch
if err := versioncontrolops.RemoveRemote(ctx, db, name); err != nil {
if strings.Contains(err.Error(), "unknown remote") {
return nil // treat as already removed
}
return fmt.Errorf("remove remote %s: %w", name, err)
} Prevention
- List remotes before removing; skip removal when the name is absent
- Copy remote names exactly (case-sensitive) rather than retyping them
- Treat 'unknown remote' as idempotent success in cleanup scripts
When it happens
Trigger: Calling RemoveRemote(ctx, db, name) where name is not a configured remote (Dolt returns 'unknown remote'), the SQL call errors, the connection is down, or the context is canceled mid-call.
Common situations: Typo in the remote name; remote already removed by another process/session; running against a repo_state.json without that remote; stale handle to a restarted Dolt server.
Related errors
- dolt_stats_gc: %w
- list Dolt remotes before git-protocol routing for peer %q: %
- failed to add remote %s: %w
- db: %s: %w
- remote-migrate gate: read remotes: %w
AI-assisted analysis of gastownhall/beads@71377f2769 (2026-08-30).
Data as JSON: /api/errors/f210fc486fe9117f.
Report an issue: GitHub.