{"record":{"id":"61cea7f6c35151b0","repo":"gastownhall/beads","slug":"db-addremote-s-w","errorCode":null,"errorMessage":"db: AddRemote %s: %w","messagePattern":"db: AddRemote (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/domain/db/remote.go","lineNumber":26,"sourceCode":")\n\nfunc NewRemoteSQLRepository(runner Runner) domain.RemoteSQLRepository {\n\treturn &remoteSQLRepositoryImpl{\n\t\trunner: runner,\n\t\tvc:     NewDoltVersionControlSQLRepository(runner),\n\t}\n}\n\ntype remoteSQLRepositoryImpl struct {\n\trunner Runner\n\tvc     DoltVersionControlSQLRepository\n}\n\nvar _ domain.RemoteSQLRepository = (*remoteSQLRepositoryImpl)(nil)\n\nfunc (r *remoteSQLRepositoryImpl) AddRemote(ctx context.Context, name, url string) error {\n\tif err := r.vc.Remote(ctx, \"add\", name, url); err != nil {\n\t\treturn fmt.Errorf(\"db: AddRemote %s: %w\", name, err)\n\t}\n\treturn nil\n}\n\nfunc (r *remoteSQLRepositoryImpl) RemoveRemote(ctx context.Context, name string) error {\n\tif err := r.vc.Remote(ctx, \"remove\", name); err != nil {\n\t\treturn fmt.Errorf(\"db: RemoveRemote %s: %w\", name, err)\n\t}\n\treturn nil\n}\n\nfunc (r *remoteSQLRepositoryImpl) ListRemotes(ctx context.Context) ([]domain.Remote, error) {\n\trows, err := r.runner.QueryContext(ctx, \"SELECT name, url FROM dolt_remotes\")\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"db: ListRemotes: query: %w\", err)\n\t}\n\tdefer rows.Close()\n","sourceCodeStart":8,"sourceCodeEnd":44,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/storage/domain/db/remote.go#L8-L44","documentation":"This error is returned by AddRemote when the underlying version-control layer (r.vc.Remote with the 'add' subcommand) fails to register a new remote. It wraps the VC/Dolt error with the remote name for context. It means the remote was not created in dolt_remotes.","triggerScenarios":"Calling AddRemote(ctx, name, url) where the underlying `dolt remote add` fails: invalid remote URL, remote name already exists, repository not initialized, or the storage backend rejects the operation.","commonSituations":"Typo in the remote URL scheme (not a valid Dolt/S3/file URL); adding a remote whose name already exists; calling sync setup before the database was initialized; running against a read-only or misconfigured Dolt data directory.","solutions":["Read the wrapped cause after the remote name to see why `remote add` failed","Verify the remote name is unique (run ListRemotes or `dolt remotes`) and the URL is valid for Dolt","Ensure the database/repository is initialized before adding remotes","If the remote already exists, remove it first (RemoveRemote) or reuse the existing entry"],"exampleFix":"// before\nerr := remotes.AddRemote(ctx, \"origin\", \"gs://bucket/db\") // fails: name exists\n// after\nexisting, _ := remotes.ListRemotes(ctx)\nif !containsRemote(existing, \"origin\") {\n    err := remotes.AddRemote(ctx, \"origin\", \"gs://bucket/db\")\n}","handlingStrategy":"validation","validationCode":"remotes, err := store.ListRemotes(ctx)\nif err != nil { return err }\nfor _, r := range remotes {\n    if r.Name == name { return fmt.Errorf(\"remote %q already exists\", name) }\n}\nif !strings.Contains(url, \"://\") { return fmt.Errorf(\"invalid remote url %q\", url) }","typeGuard":"func isValidRemoteURL(url string) bool {\n    return strings.HasPrefix(url, \"aws://\") || strings.HasPrefix(url, \"gs://\") || strings.HasPrefix(url, \"file://\") || strings.Contains(url, \".dolt\")\n}","tryCatchPattern":null,"preventionTips":["Check for an existing remote with the same name before adding","Validate the URL scheme before calling AddRemote","Initialize the repository before configuring remotes"],"tags":["database","git-remote","dolt","sync"],"backgroundTag":"remote-add-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}