{"record":{"id":"b18eaf2fee9f1626","repo":"gastownhall/beads","slug":"dolt-remote-remove-failed-s-w","errorCode":null,"errorMessage":"dolt remote remove failed: %s: %w","messagePattern":"dolt remote remove failed: (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/doltutil/remotes.go","lineNumber":182,"sourceCode":"\tcmd := exec.Command(\"dolt\", \"remote\", \"add\", name, url) // #nosec G204 -- validated argv\n\tcmd.Dir = dbPath\n\tout, err := cmd.CombinedOutput()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"dolt remote add failed: %s: %w\", strings.TrimSpace(string(out)), err)\n\t}\n\treturn nil\n}\n\n// RemoveCLIRemote removes a remote at the filesystem level via dolt CLI.\nfunc RemoveCLIRemote(dbPath, name string) error {\n\tif err := remotecache.ValidateRemoteName(name); err != nil {\n\t\treturn fmt.Errorf(\"invalid remote name: %w\", err)\n\t}\n\tcmd := exec.Command(\"dolt\", \"remote\", \"remove\", name) // #nosec G204 -- validated argv\n\tcmd.Dir = dbPath\n\tout, err := cmd.CombinedOutput()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"dolt remote remove failed: %s: %w\", strings.TrimSpace(string(out)), err)\n\t}\n\treturn nil\n}\n\n// FindCLIRemote returns the URL for a named remote in dbPath, or \"\" when the\n// directory cannot be inspected or the remote is absent.\nfunc FindCLIRemote(dbPath, name string) string {\n\tremotes, err := ListCLIRemotes(dbPath)\n\tif err != nil {\n\t\treturn \"\"\n\t}\n\tfor _, r := range remotes {\n\t\tif r.Name == name {\n\t\t\treturn r.URL\n\t\t}\n\t}\n\treturn \"\"\n}","sourceCodeStart":164,"sourceCodeEnd":200,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/storage/doltutil/remotes.go#L164-L200","documentation":"RemoveCLIRemote runs `dolt remote remove <name>` with cmd.Dir=dbPath and, on non-zero exit or exec failure, returns dolt's combined output plus the exec error wrapped as \"dolt remote remove failed\". The dolt subprocess refused or could not perform the removal.","triggerScenarios":"Calling RemoveCLIRemote/EnsureCLIRemote when the named remote does not exist in the dolt DB; dbPath is not an initialized dolt database; the dolt binary is missing from PATH; a concurrent dolt process or stale lock blocks the operation; dbPath is read-only.","commonSituations":"Removing a remote that was never added or was already removed (non-idempotent caller); two bd processes racing on the same database; CI environment without dolt installed; database directory mounted read-only.","solutions":["Read the %s portion of the error — dolt's output states whether the remote was missing vs. an environment failure","Check `dolt remote -v` in dbPath; if the remote is absent, treat removal as already done","Guard removal with FindCLIRemote so a missing remote is a no-op instead of an error","Verify dolt is installed and no other bd/dolt process holds the database","Fix filesystem permissions on dbPath if the failure is a write/lock error"],"exampleFix":"// before\nif err := doltutil.RemoveCLIRemote(dbPath, name); err != nil {\n\treturn err // fails when remote does not exist\n}\n\n// after\nif doltutil.FindCLIRemote(dbPath, name) != \"\" {\n\tif err := doltutil.RemoveCLIRemote(dbPath, name); err != nil {\n\t\treturn fmt.Errorf(\"remove stale remote: %w\", err)\n\t}\n}","handlingStrategy":"try-catch","validationCode":"if doltutil.FindCLIRemote(dbPath, name) == \"\" {\n\treturn nil // nothing to remove; avoid the dolt round-trip entirely\n}","typeGuard":"func isRemoteMissingError(err error) bool {\n\treturn err != nil && strings.Contains(strings.ToLower(err.Error()), \"not found\")\n}","tryCatchPattern":"if err := doltutil.RemoveCLIRemote(dbPath, name); err != nil {\n\tif isRemoteMissingError(err) {\n\t\treturn nil // already gone — treat as success\n\t}\n\treturn fmt.Errorf(\"removing dolt remote %q: %w\", name, err)\n}","preventionTips":["Check FindCLIRemote before removing so removal is idempotent","Avoid running concurrent bd sync/dolt processes against the same database directory","Ensure the dolt binary is present and dbPath is writable before mutating CLI remotes"],"tags":["dolt","cli","subprocess","remote","exec"],"backgroundTag":"dolt-remote-remove-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}