{"record":{"id":"7ebf6bbbb460605e","repo":"gastownhall/beads","slug":"add-remote-s-w","errorCode":null,"errorMessage":"add remote %s: %w","messagePattern":"add remote (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/bd/dolt.go","lineNumber":1565,"sourceCode":"\tif err != nil {\n\t\treturn doltRemoteAddResult{}, fmt.Errorf(\"list existing remotes: %w\", err)\n\t}\n\n\texistingURL := findDoltRemoteURL(remotes, name)\n\texistingFromDiskOnly := false\n\tif existingURL == \"\" {\n\t\t// An empty listing is not proof the remote is absent: a freshly\n\t\t// (auto-)started sql-server can report empty dolt_remotes while the\n\t\t// remote is persisted on disk (GH#2118, wy-6k7f7). Recover the\n\t\t// persisted URL so the add gets the same match/confirm treatment it\n\t\t// would after the window, instead of silently writing over an\n\t\t// invisible remote.\n\t\texistingURL = findDoltRemoteURL(persistedRemoteInfosFor(st), name)\n\t\texistingFromDiskOnly = existingURL != \"\"\n\t}\n\tif existingURL == \"\" {\n\t\tif err := st.AddRemote(ctx, name, url); err != nil {\n\t\t\treturn doltRemoteAddResult{}, fmt.Errorf(\"add remote %s: %w\", name, err)\n\t\t}\n\t\treturn doltRemoteAddResult{}, nil\n\t}\n\n\tif doltutil.RemoteURLsMatch(existingURL, url) {\n\t\treturn doltRemoteAddResult{}, nil\n\t}\n\n\tif !confirm(\"SQL server\", name, existingURL, url) {\n\t\treturn doltRemoteAddResult{Canceled: true}, nil\n\t}\n\tif err := st.RemoveRemote(ctx, name); err != nil {\n\t\t// A remote known only from disk may not be removable through a\n\t\t// cold-started server that doesn't see it yet; the confirmed add\n\t\t// below is what establishes the new URL either way.\n\t\tif !existingFromDiskOnly {\n\t\t\treturn doltRemoteAddResult{}, fmt.Errorf(\"remove existing remote %s: %w\", name, err)\n\t\t}","sourceCodeStart":1547,"sourceCodeEnd":1583,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/cmd/bd/dolt.go#L1547-L1583","documentation":"ensureDoltRemote adds the remote when no existing remote with that name is found (in the listing or persisted on disk). If st.AddRemote fails, the error is wrapped as 'add remote <name>'. It fails fast before any URL-comparison or replacement logic runs.","triggerScenarios":"`bd dolt remote add <name> <url>` (or push-time adoption) when AddRemote errors: invalid URL rejected by the driver, server write failure, or a remote materialized on disk between the listing and the add (race).","commonSituations":"Malformed remote URL (bad scheme/path); Dolt server hiccup; concurrent bd processes both trying to add the same remote name.","solutions":["Check the remote URL format (valid git/https/file URL for Dolt remotes) and retry","Verify server health and retry — AddRemote may have failed transiently","Run `bd dolt remote -v` to see the current state, then re-add or remove conflicting entries","Avoid concurrent bd mutations on the same workspace from multiple processes"],"exampleFix":"// before\nbd dolt remote add origin not-a-url\n// after\nbd dolt remote add origin https://github.com/org/repo.git","handlingStrategy":"validation","validationCode":"u, err := url.Parse(remoteURL)\nif err != nil || (u.Scheme != \"https\" && u.Scheme != \"http\" && u.Scheme != \"file\" && u.Scheme != \"ssh\") {\n  return fmt.Errorf(\"invalid remote URL: %q\", remoteURL)\n}","typeGuard":null,"tryCatchPattern":"res, err := ensureDoltRemote(ctx, st, name, url, confirm)\nif err != nil {\n  if strings.Contains(err.Error(), \"add remote \"+name) {\n    // check URL validity and server state before retrying\n    return res, err\n  }\n}","preventionTips":["Validate remote URLs before passing them to bd dolt remote add","Don't run concurrent remote mutations from multiple shells/CI jobs","Check `bd dolt remote -v` first to know whether add will be a create or replace","Use consistent URL normalization (trailing slashes, scheme) across environments"],"tags":["dolt","remote","add","url"],"backgroundTag":"dolt-add-remote-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}