{"record":{"id":"f210fc486fe9117f","repo":"gastownhall/beads","slug":"remove-remote-s-w","errorCode":null,"errorMessage":"remove remote %s: %w","messagePattern":"remove remote (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/versioncontrolops/remotes.go","lineNumber":32,"sourceCode":"\t\treturn nil, fmt.Errorf(\"list remotes: %w\", err)\n\t}\n\tdefer rows.Close()\n\n\tvar remotes []storage.RemoteInfo\n\tfor rows.Next() {\n\t\tvar r storage.RemoteInfo\n\t\tif err := rows.Scan(&r.Name, &r.URL); err != nil {\n\t\t\treturn nil, fmt.Errorf(\"scan remote: %w\", err)\n\t\t}\n\t\tremotes = append(remotes, r)\n\t}\n\treturn remotes, rows.Err()\n}\n\n// RemoveRemote removes a configured Dolt remote.\nfunc RemoveRemote(ctx context.Context, db DBConn, name string) error {\n\tif _, err := db.ExecContext(ctx, \"CALL DOLT_REMOTE('remove', ?)\", name); err != nil {\n\t\treturn fmt.Errorf(\"remove remote %s: %w\", name, err)\n\t}\n\treturn nil\n}\n\n// Fetch fetches refs from a remote without merging.\n//\n// If user is non-empty, authenticates with that user — DOLT_REMOTE_PASSWORD\n// must be set in the in-process Dolt server's environment.\n//\n// A failed DOLT_FETCH can leave orphaned tmp_pack_* files in the\n// git-remote-cache; the embedded store's connection teardown sweeps those\n// (cleanGitRemoteCacheGarbage). Do NOT run DOLT_GC here: dolt_gc invalidates\n// every other open session on the same engine, so a failed fetch would break\n// concurrent in-flight connections (bd-6dnrw.10).\nfunc Fetch(ctx context.Context, db DBConn, peer, user string) error {\n\terr := withRemoteEnvGuards(func() error {\n\t\tif user != \"\" {\n\t\t\t_, err := db.ExecContext(ctx, \"CALL DOLT_FETCH('--user', ?, ?)\", user, peer)","sourceCodeStart":14,"sourceCodeEnd":50,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/storage/versioncontrolops/remotes.go#L14-L50","documentation":"RemoveRemote removes a configured Dolt remote by executing CALL DOLT_REMOTE('remove', ?). This error wraps any failure of that stored-procedure call — the most common being that the named remote does not exist, or the Dolt engine rejected/failed the removal. The remote name is embedded in the message to identify which removal failed.","triggerScenarios":"Calling RemoveRemote(ctx, db, name) where name is not a configured remote (Dolt returns 'unknown remote'), the SQL call errors, the connection is down, or the context is canceled mid-call.","commonSituations":"Typo in the remote name; remote already removed by another process/session; running against a repo_state.json without that remote; stale handle to a restarted Dolt server.","solutions":["Call ListRemotes first and confirm the remote name exists (exact match, case-sensitive)","Fix the remote name typo or skip removal if it is already absent","Verify the DB connection is alive and points at the right database","Inspect the wrapped error for the Dolt-level message (e.g. unknown remote vs connection refused)"],"exampleFix":"// before\nif err := versioncontrolops.RemoveRemote(ctx, db, \"origin\"); err != nil {\n\treturn err\n}\n// after\nremotes, _ := versioncontrolops.ListRemotes(ctx, db)\nexists := false\nfor _, r := range remotes {\n\tif r.Name == \"origin\" {\n\t\texists = true\n\t}\n}\nif exists {\n\tif err := versioncontrolops.RemoveRemote(ctx, db, \"origin\"); err != nil {\n\t\treturn fmt.Errorf(\"remove remote origin: %w\", err)\n\t}\n}","handlingStrategy":"validation","validationCode":"remotes, err := versioncontrolops.ListRemotes(ctx, db)\nif err != nil {\n\treturn err\n}\nfound := false\nfor _, r := range remotes {\n\tif r.Name == name {\n\t\tfound = true\n\t}\n}\nif !found {\n\treturn nil // already absent; nothing to remove\n}","typeGuard":"func remoteExists(remotes []storage.RemoteInfo, name string) bool {\n\tfor _, r := range remotes {\n\t\tif r.Name == name {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}","tryCatchPattern":"if err := versioncontrolops.RemoveRemote(ctx, db, name); err != nil {\n\tif strings.Contains(err.Error(), \"unknown remote\") {\n\t\treturn nil // treat as already removed\n\t}\n\treturn fmt.Errorf(\"remove remote %s: %w\", name, err)\n}","preventionTips":["List remotes before removing; skip removal when the name is absent","Copy remote names exactly (case-sensitive) rather than retyping them","Treat 'unknown remote' as idempotent success in cleanup scripts"],"tags":["dolt","remotes","stored-procedure"],"backgroundTag":"dolt-remote-not-found","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}