{"record":{"id":"daf931679c7bb7c9","repo":"gastownhall/beads","slug":"push-to-s-s-w","errorCode":null,"errorMessage":"push to %s/%s: %w","messagePattern":"push to (.+?)/(.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/versioncontrolops/remotes.go","lineNumber":76,"sourceCode":"\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 {\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}","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/storage/versioncontrolops/remotes.go#L58-L94","documentation":"Push runs CALL DOLT_PUSH(?, ?) (with optional '--user' authentication) to push the given branch to the named remote. This error wraps any failure of the DOLT_PUSH call: non-fast-forward rejection, missing remote, authentication failure, or transport/connection errors. The message names the remote/branch pair to pinpoint the failing push.","triggerScenarios":"Calling Push(ctx, db, remote, branch, user) where the remote branch has diverged (non-fast-forward), the remote does not exist, authentication fails (missing/incorrect DOLT_REMOTE_PASSWORD when user is set), the remote rejects the write (e.g. CLONE_ADMIN enforcement), or ExecContext errors.","commonSituations":"Pushing to a remotesapi server that enforces authentication without passing user/DOLT_REMOTE_PASSWORD; remote moved ahead (diverged histories) — needs ForcePush; typo in remote or branch name; peer storage full or read-only.","solutions":["Confirm the remote and branch names are correct via ListRemotes","If authentication is required, pass a non-empty user and ensure DOLT_REMOTE_PASSWORD is set in the Dolt server environment","If the push was rejected as non-fast-forward, use ForcePush deliberately after verifying the divergence is intended to be overwritten","Fetch and merge/rebase local work with the remote before pushing again","Inspect the wrapped Dolt error for the exact server rejection reason"],"exampleFix":"// before\nif err := versioncontrolops.Push(ctx, db, \"origin\", \"main\", \"\"); err != nil {\n\treturn err\n}\n// after\nif err := versioncontrolops.Push(ctx, db, \"origin\", \"main\", \"\"); err != nil {\n\tif strings.Contains(err.Error(), \"non-fast-forward\") {\n\t\treturn versioncontrolops.ForcePush(ctx, db, \"origin\", \"main\", \"\") // deliberate overwrite\n\t}\n\treturn fmt.Errorf(\"push to origin/main: %w\", err)\n}","handlingStrategy":"try-catch","validationCode":"// Confirm the remote exists and auth env is ready before pushing\nremotes, err := versioncontrolops.ListRemotes(ctx, db)\nif err != nil {\n\treturn err\n}\nremoteOK := false\nfor _, r := range remotes {\n\tif r.Name == remote {\n\t\tremoteOK = true\n\t}\n}\nif !remoteOK {\n\treturn fmt.Errorf(\"remote %q not configured\", remote)\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 isNonFastForward(err error) bool {\n\treturn strings.Contains(strings.ToLower(err.Error()), \"non-fast-forward\")\n}","tryCatchPattern":"if err := versioncontrolops.Push(ctx, db, remote, branch, user); err != nil {\n\tif isNonFastForward(err) {\n\t\t// decide deliberately: fetch+merge, or explicit ForcePush\n\t\treturn fmt.Errorf(\"push to %s/%s diverged: %w\", remote, branch, err)\n\t}\n\treturn fmt.Errorf(\"push to %s/%s: %w\", remote, branch, err)\n}","preventionTips":["Fetch and merge from the remote before pushing to avoid non-fast-forward rejections","Always supply user + DOLT_REMOTE_PASSWORD when pushing to remotesapi servers enforcing CLONE_ADMIN auth","Validate remote and branch names against ListRemotes before pushing","Use ForcePush only as an explicit, reviewed decision — never as a blanket fallback"],"tags":["dolt","network","push","authentication","remotes"],"backgroundTag":"dolt-push-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}