{"record":{"id":"162895531bd8c791","repo":"gastownhall/beads","slug":"fetch-from-s-w","errorCode":null,"errorMessage":"fetch from %s: %w","messagePattern":"fetch from (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/versioncontrolops/remotes.go","lineNumber":57,"sourceCode":"// 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)\n\t\t\treturn err\n\t\t}\n\t\t_, err := db.ExecContext(ctx, \"CALL DOLT_FETCH(?)\", peer)\n\t\treturn err\n\t})\n\tif err != nil {\n\t\treturn fmt.Errorf(\"fetch from %s: %w\", peer, err)\n\t}\n\treturn nil\n}\n\n// Push pushes the given branch to the named remote.\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. Required when\n// pushing to a remotesapi server that enforces CLONE_ADMIN authentication.\nfunc Push(ctx context.Context, db DBConn, remote, branch, user string) error {\n\terr := withRemoteEnvGuards(func() error {\n\t\tif user != \"\" {\n\t\t\t_, err := db.ExecContext(ctx, \"CALL DOLT_PUSH('--user', ?, ?, ?)\", user, remote, branch)\n\t\t\treturn err\n\t\t}\n\t\t_, err := db.ExecContext(ctx, \"CALL DOLT_PUSH(?, ?)\", remote, branch)\n\t\treturn err\n\t})\n\tif err != nil {","sourceCodeStart":39,"sourceCodeEnd":75,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/storage/versioncontrolops/remotes.go#L39-L75","documentation":"Fetch runs CALL DOLT_FETCH(?) (or with '--user' when credentials are supplied) to fetch refs from a peer remote without merging. This error wraps any failure of the DOLT_FETCH call: unreachable peer, authentication failure, or a Dolt-internal fetch error. Per the source, a failed DOLT_FETCH can leave orphaned tmp_pack_* files in the git-remote-cache; the embedded store sweeps these on connection teardown, and DOLT_GC must NOT be run as a fix because it invalidates other open sessions (bd-6dnrw.10).","triggerScenarios":"Calling Fetch(ctx, db, peer, user) where the peer remote URL is unreachable, credentials are wrong or DOLT_REMOTE_PASSWORD is unset when user is non-empty, the remote rejects the fetch, or ExecContext fails (connection/context error).","commonSituations":"Peer server down or wrong URL; missing DOLT_REMOTE_PASSWORD in the in-process Dolt server environment when authenticating; network/firewall blocking the peer; SSL/TLS mismatch; transient network blips during large fetches.","solutions":["Verify the peer remote is reachable (curl/ping its URL) and the name is correct","If user is non-empty, ensure DOLT_REMOTE_PASSWORD is set in the Dolt server's environment before the call","Retry the fetch after a transient failure — do NOT run DOLT_GC to clean up (it breaks concurrent sessions); tmp_pack_* garbage is swept on connection teardown","Inspect the wrapped error for the Dolt fetch message (auth vs network vs unknown remote)","Check TLS/certificate configuration if the peer uses HTTPS"],"exampleFix":"// before\nif err := versioncontrolops.Fetch(ctx, db, peer, user); err != nil {\n\treturn err\n}\n// after\nif err := versioncontrolops.Fetch(ctx, db, peer, user); err != nil {\n\tvar netErr net.Error\n\tif errors.As(err, &netErr) && netErr.Timeout() {\n\t\treturn versioncontrolops.Fetch(ctx, db, peer, user) // retry transient\n\t}\n\treturn fmt.Errorf(\"fetch from %s: %w\", peer, err)\n}","handlingStrategy":"retry","validationCode":"// Verify the peer is configured and the auth env is present before fetching\nremotes, err := versioncontrolops.ListRemotes(ctx, db)\nif err != nil {\n\treturn err\n}\npeerOK := false\nfor _, r := range remotes {\n\tif r.Name == peer {\n\t\tpeerOK = true\n\t}\n}\nif !peerOK {\n\treturn fmt.Errorf(\"peer %q not configured\", peer)\n}\nif user != \"\" && os.Getenv(\"DOLT_REMOTE_PASSWORD\") == \"\" {\n\treturn fmt.Errorf(\"DOLT_REMOTE_PASSWORD must be set in the Dolt server env for user auth\")\n}","typeGuard":"func isTransientFetchErr(err error) bool {\n\tvar netErr net.Error\n\treturn errors.As(err, &netErr) && netErr.Timeout()\n}","tryCatchPattern":"err := versioncontrolops.Fetch(ctx, db, peer, user)\nfor i := 0; err != nil && i < 3 && isTransientFetchErr(err); i++ {\n\ttime.Sleep(time.Second << i)\n\terr = versioncontrolops.Fetch(ctx, db, peer, user)\n}\nif err != nil {\n\treturn fmt.Errorf(\"fetch from %s: %w\", peer, err)\n}","preventionTips":["Set DOLT_REMOTE_PASSWORD in the Dolt server environment before any authenticated fetch","Verify peer reachability (URL, firewall, TLS) before scheduling fetches","Never run DOLT_GC after a failed fetch — tmp_pack_* garbage is swept on connection teardown and GC breaks concurrent sessions","Use bounded retry with backoff for transient network errors only"],"tags":["dolt","network","fetch","authentication","remotes"],"backgroundTag":"dolt-fetch-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}