{"record":{"id":"9e366043c73d4666","repo":"gastownhall/beads","slug":"failed-to-add-remote-s-w","errorCode":null,"errorMessage":"failed to add remote %s: %w","messagePattern":"failed to add remote (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/dolt/store.go","lineNumber":4997,"sourceCode":"}\n\n// HasRemote checks if a Dolt remote with the given name exists.\nfunc (s *DoltStore) HasRemote(ctx context.Context, name string) (bool, error) {\n\tvar count int\n\terr := s.queryRowContext(ctx, func(row *sql.Row) error {\n\t\treturn row.Scan(&count)\n\t}, \"SELECT COUNT(*) FROM dolt_remotes WHERE name = ?\", name)\n\tif err != nil {\n\t\treturn false, fmt.Errorf(\"failed to check remote %s: %w\", name, err)\n\t}\n\treturn count > 0, nil\n}\n\n// AddRemote adds a Dolt remote\nfunc (s *DoltStore) AddRemote(ctx context.Context, name, url string) error {\n\t_, err := s.db.ExecContext(ctx, \"CALL DOLT_REMOTE('add', ?, ?)\", name, url)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to add remote %s: %w\", name, err)\n\t}\n\treturn nil\n}\n\n// Status returns the current Dolt status (staged/unstaged changes)\nfunc (s *DoltStore) Status(ctx context.Context) (*DoltStatus, error) {\n\treturn versioncontrolops.Status(ctx, s.db)\n}\n\n// DoltStatus is an alias for storage.Status.\ntype DoltStatus = storage.Status\n\n// StatusEntry is an alias for storage.StatusEntry.\ntype StatusEntry = storage.StatusEntry\n","sourceCodeStart":4979,"sourceCodeEnd":5012,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/storage/dolt/store.go#L4979-L5012","documentation":"AddRemote runs CALL DOLT_REMOTE('add', ?, ?) to register a named remote with a URL. This error wraps a failure of that stored-procedure call. Dolt rejects the operation if the remote name already exists, the URL is malformed/unsupported, or the procedure fails at the storage layer (read-only database, non-Dolt database, server error).","triggerScenarios":"Calling AddRemote(ctx, name, url) where DOLT_REMOTE('add',...) errors: duplicate remote name, invalid URL scheme (not a file path, gs://, aws://, or http(s) URL), read-only connection, or executing against a non-Dolt backend.","commonSituations":"Re-running setup scripts that re-add an existing 'origin'; typos in remote URLs (missing scheme or path); pointing at cloud remotes without credentials/config; running inside a read-only replica.","solutions":["Check for an existing remote first (HasRemote) and skip/update instead of re-adding.","Validate the URL format (local path, http(s), aws://, or gs://) before calling.","Run `dolt remotes list` / SELECT * FROM dolt_remotes to inspect current remotes and the exact server error.","Ensure the database is writable and is a Dolt database.","Verify credentials/config for cloud remotes (AWS/GCS) are present on the server."],"exampleFix":"// before\nif err := store.AddRemote(ctx, \"origin\", url); err != nil { return err }\n// after\nexists, err := store.HasRemote(ctx, \"origin\")\nif err != nil { return err }\nif !exists {\n    if err := store.AddRemote(ctx, \"origin\", url); err != nil { return err }\n}","handlingStrategy":"validation","validationCode":"var validRemoteURL = regexp.MustCompile(`^(https?://|aws://|gs://|/[\\w./-])`)\nif !validRemoteURL.MatchString(url) { return fmt.Errorf(\"invalid remote URL: %s\", url) }\nexists, err := store.HasRemote(ctx, name)\nif err == nil && exists { return fmt.Errorf(\"remote %q already exists\", name) }","typeGuard":null,"tryCatchPattern":"err := store.AddRemote(ctx, name, url)\nif err != nil {\n    if exists, _ := store.HasRemote(ctx, name); exists {\n        return nil // idempotent: remote already added\n    }\n    return fmt.Errorf(\"add remote %q: %w\", name, err)\n}","preventionTips":["Make setup scripts idempotent with a HasRemote check","Validate URL scheme before calling (local path, http(s), aws://, gs://)","Configure cloud credentials on the server before adding cloud remotes","Don't add remotes through read-only connections"],"tags":["dolt","remote","configuration","stored-procedure"],"backgroundTag":"dolt-remote-add-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}