gastownhall/beads · error
add remote %s: %w
Error message
add remote %s: %w
What it means
AddRemoteIfNotExists runs CALL DOLT_REMOTE('add', name, url) and wraps any failure other than "already exists" as "add remote <name>". It deliberately tolerates re-adding an existing remote, so this error means the stored procedure failed for another reason: invalid URL, bad remote name, or a Dolt engine error.
Source
Thrown at internal/storage/issueops/federation.go:143
}
return peers, rows.Err()
}
// RemoveFederationPeerInTx deletes a federation peer by name.
func RemoveFederationPeerInTx(ctx context.Context, tx *sql.Tx, name string) error {
_, err := tx.ExecContext(ctx, "DELETE FROM federation_peers WHERE name = ?", name)
if err != nil {
return fmt.Errorf("remove federation peer: %w", err)
}
return nil
}
// AddRemoteIfNotExists adds a Dolt remote, ignoring "already exists" errors.
// This is a helper used when adding federation peers that also need a Dolt remote.
func AddRemoteIfNotExists(ctx context.Context, tx *sql.Tx, name, url string) error {
_, err := tx.ExecContext(ctx, "CALL DOLT_REMOTE('add', ?, ?)", name, url)
if err != nil && !strings.Contains(err.Error(), "already exists") {
return fmt.Errorf("add remote %s: %w", name, err)
}
return nil
}
View on GitHub (pinned to 71377f2769)
Solutions
- Read the wrapped error — if it contains "already exists" this is not a failure; otherwise inspect the DOLT_REMOTE message
- Verify the URL is well-formed and reachable (https://host/org/repo)
- Check the remote name for invalid characters and validate it before the call
- Confirm the backend is Dolt and supports the DOLT_REMOTE stored procedure
Example fix
// before
url := cfg.Remote // "host/org/repo" (missing scheme)
err := issueops.AddRemoteIfNotExists(ctx, tx, "origin", url)
// after
url := cfg.Remote
if !strings.HasPrefix(url, "https://") && !strings.HasPrefix(url, "http://") {
url = "https://" + url
}
err := issueops.AddRemoteIfNotExists(ctx, tx, "origin", url) Defensive patterns
Strategy: validation
Validate before calling
func validRemote(name, url string) error {
if name == "" || strings.ContainsAny(name, " \t/") {
return fmt.Errorf("invalid remote name %q", name)
}
u, err := neturl.Parse(url)
if err != nil || u.Scheme == "" || u.Host == "" {
return fmt.Errorf("invalid remote url %q", url)
}
return nil
}
// call validRemote(name, url) before AddRemoteIfNotExists Try / catch
err := issueops.AddRemoteIfNotExists(ctx, tx, name, url)
if err != nil {
if strings.Contains(err.Error(), "already exists") {
return nil // tolerated by design; should not surface
}
return fmt.Errorf("add remote %s: %w", name, err)
} Prevention
- Validate URL scheme/host and remote-name characters before calling
- Remember "already exists" is intentionally swallowed — treat other messages as real failures
- Confirm the backend is Dolt and supports DOLT_REMOTE before using this helper
When it happens
Trigger: Calling AddRemoteIfNotExists with an unreachable/malformed remote URL, an invalid remote name, or when the Dolt stored procedure rejects the call for reasons other than the remote already existing.
Common situations: Typo in the remote URL (missing scheme, wrong host); remote name with invalid characters; running against a non-Dolt backend that lacks the DOLT_REMOTE procedure; network/auth failure reaching the remote on validation.
Related errors
- failed to add dolt remote: %w
- failed to commit federation peer: %w
- failed to push to peer %s: %w
- peer remote %q uses git protocol and requires CLI routing: %
- CreateRemote %s: %w
AI-assisted analysis of gastownhall/beads@71377f2769 (2026-08-30).
Data as JSON: /api/errors/954fe0b6e6b6d9da.
Report an issue: GitHub.