{"record":{"id":"69c98ebd2193e8ac","repo":"gastownhall/beads","slug":"force-push-to-s-s-w","errorCode":null,"errorMessage":"force push to %s/%s: %w","messagePattern":"force push to (.+?)/(.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/versioncontrolops/remotes.go","lineNumber":93,"sourceCode":"\tif err != nil {\n\t\treturn fmt.Errorf(\"push to %s/%s: %w\", remote, branch, err)\n\t}\n\treturn nil\n}\n\n// ForcePush force-pushes the given branch to the named remote.\n// See Push for the user/auth contract.\nfunc ForcePush(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('--force', '--user', ?, ?, ?)\", user, remote, branch)\n\t\t\treturn err\n\t\t}\n\t\t_, err := db.ExecContext(ctx, \"CALL DOLT_PUSH('--force', ?, ?)\", remote, branch)\n\t\treturn err\n\t})\n\tif err != nil {\n\t\treturn fmt.Errorf(\"force push to %s/%s: %w\", remote, branch, err)\n\t}\n\treturn nil\n}\n\n// Pull pulls changes from the named remote by fetching the branch and merging\n// the remote tracking ref. This is equivalent to DOLT_PULL(remote, branch) but\n// avoids a nil-pointer panic in embedded Dolt when upstream branch tracking is\n// not configured in repo_state.json (GH#3144). The merge runs through\n// MergeAndSettle (bd-6dnrw.40), so safe conflict classes are auto-resolved and\n// FK cascade violations repaired, matching server-mode pulls.\n//\n// db must be a single session (see MergeAndSettle). See Push for the\n// user/auth contract; only the fetch step authenticates, since the merge step\n// is local.\nfunc Pull(ctx context.Context, db DBConn, remote, branch, user string) error {\n\treturn PullWithStrategy(ctx, db, remote, branch, user, \"\")\n}\n","sourceCodeStart":75,"sourceCodeEnd":111,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/storage/versioncontrolops/remotes.go#L75-L111","documentation":"ForcePush wraps a failed CALL DOLT_PUSH('--force', remote, branch) against the embedded Dolt engine with \"force push to <remote>/<branch>: <underlying>\". The library throws it because the remote-side or engine-side push operation returned an error and ForcePush must attribute it to the specific remote/branch pair. Common underlying causes are authentication failures (missing DOLT_REMOTE_PASSWORD / wrong --user), unknown remote or branch, network failures reaching the remote, and non-fast-forward rejections when the remote enforces protections despite --force.","triggerScenarios":"Calling ForcePush when: the remote name is not configured in dolt_remotes; the branch does not exist locally or remotely; credentials are absent/invalid (remotesapi server enforcing CLONE_ADMIN auth without --user and DOLT_REMOTE_PASSWORD set in the server env); the remote is unreachable; or a Dolt server-side guard still rejects the force update.","commonSituations":"Recovering a rewritten history after rebase/sync conflicts; network or VPN down during bd dolt push; a teammate rotated remote credentials; pushing to a remote that was added under a different name than passed in.","solutions":["Verify the remote exists with bd vc remote list (SELECT name, url FROM dolt_remotes) and that the branch name is exact.","Ensure DOLT_REMOTE_PASSWORD is set in the in-process Dolt server's environment, or pass a non-empty user so DOLT_PUSH('--force','--user',...) is used.","Inspect the wrapped underlying error: for auth errors fix credentials; for unknown-remote add the remote; for network errors retry after connectivity is restored.","If the remote rejects non-fast-forward with branch protections, coordinate with the remote admin rather than retrying."],"exampleFix":"// before\nerr := versioncontrolops.ForcePush(ctx, db, \"origin\", \"main\", \"\") // no creds, empty user\n// after\nos.Setenv(\"DOLT_REMOTE_PASSWORD\", token) // in the server process env\nerr := versioncontrolops.ForcePush(ctx, db, \"origin\", \"main\", \"admin\")","handlingStrategy":"try-catch","validationCode":"var remotes []storage.RemoteInfo\nremotes, err := versioncontrolops.ListRemotes(ctx, db)\nif err != nil { return err }\nfound := false\nfor _, r := range remotes {\n    if r.Name == remote { found = true }\n}\nif !found { return fmt.Errorf(\"remote %q not configured\", remote) }\nif os.Getenv(\"DOLT_REMOTE_PASSWORD\") == \"\" && user == \"\" {\n    return fmt.Errorf(\"push to %s needs --user and DOLT_REMOTE_PASSWORD\", remote)\n}","typeGuard":"func isForcePushErr(err error) (remote, branch string, ok bool) {\n    if err == nil { return \"\", \"\", false }\n    msg := err.Error()\n    if !strings.HasPrefix(msg, \"force push to \") { return \"\", \"\", false }\n    rest := strings.TrimPrefix(msg, \"force push to \")\n    i := strings.Index(rest, \": \")\n    if i < 0 { return \"\", \"\", false }\n    parts := strings.SplitN(rest[:i], \"/\", 2)\n    if len(parts) != 2 { return \"\", \"\", false }\n    return parts[0], parts[1], true\n}","tryCatchPattern":"err := versioncontrolops.ForcePush(ctx, db, remote, branch, user)\nif err != nil {\n    var opErr *net.OpError\n    if errors.As(err, &opErr) {\n        // network problem: retry after connectivity check\n    } else if strings.Contains(err.Error(), \"authentication\") || strings.Contains(err.Error(), \"permission\") {\n        // refresh DOLT_REMOTE_PASSWORD / user and retry once\n    }\n    return fmt.Errorf(\"force push failed: %w\", err)\n}","preventionTips":["Always call ListRemotes first to confirm the remote name exists before pushing.","Set DOLT_REMOTE_PASSWORD in the server process environment whenever a remote requires auth, and pass the matching user.","Run a cheap Fetch(remote) before ForcePush to validate connectivity and credentials.","Only force-push branches you own; for shared branches prefer Push and resolve divergence locally."],"tags":["git","dolt","remote","push","authentication"],"backgroundTag":"git-push-rejected","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}