gastownhall/beads · error
push to %s/%s: %w
Error message
push to %s/%s: %w
What it means
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.
Source
Thrown at internal/storage/versioncontrolops/remotes.go:76
}
return nil
}
// Push pushes the given branch to the named remote.
// If user is non-empty, authenticates with that user — DOLT_REMOTE_PASSWORD
// must be set in the in-process Dolt server's environment. Required when
// pushing to a remotesapi server that enforces CLONE_ADMIN authentication.
func Push(ctx context.Context, db DBConn, remote, branch, user string) error {
err := withRemoteEnvGuards(func() error {
if user != "" {
_, err := db.ExecContext(ctx, "CALL DOLT_PUSH('--user', ?, ?, ?)", user, remote, branch)
return err
}
_, err := db.ExecContext(ctx, "CALL DOLT_PUSH(?, ?)", remote, branch)
return err
})
if err != nil {
return fmt.Errorf("push to %s/%s: %w", remote, branch, err)
}
return nil
}
// ForcePush force-pushes the given branch to the named remote.
// See Push for the user/auth contract.
func ForcePush(ctx context.Context, db DBConn, remote, branch, user string) error {
err := withRemoteEnvGuards(func() error {
if user != "" {
_, err := db.ExecContext(ctx, "CALL DOLT_PUSH('--force', '--user', ?, ?, ?)", user, remote, branch)
return err
}
_, err := db.ExecContext(ctx, "CALL DOLT_PUSH('--force', ?, ?)", remote, branch)
return err
})
if err != nil {
return fmt.Errorf("force push to %s/%s: %w", remote, branch, err)
}View on GitHub (pinned to 71377f2769)
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
Example fix
// before
if err := versioncontrolops.Push(ctx, db, "origin", "main", ""); err != nil {
return err
}
// after
if err := versioncontrolops.Push(ctx, db, "origin", "main", ""); err != nil {
if strings.Contains(err.Error(), "non-fast-forward") {
return versioncontrolops.ForcePush(ctx, db, "origin", "main", "") // deliberate overwrite
}
return fmt.Errorf("push to origin/main: %w", err)
} Defensive patterns
Strategy: try-catch
Validate before calling
// Confirm the remote exists and auth env is ready before pushing
remotes, err := versioncontrolops.ListRemotes(ctx, db)
if err != nil {
return err
}
remoteOK := false
for _, r := range remotes {
if r.Name == remote {
remoteOK = true
}
}
if !remoteOK {
return fmt.Errorf("remote %q not configured", remote)
}
if user != "" && os.Getenv("DOLT_REMOTE_PASSWORD") == "" {
return fmt.Errorf("DOLT_REMOTE_PASSWORD must be set in the Dolt server env for user auth")
} Type guard
func isNonFastForward(err error) bool {
return strings.Contains(strings.ToLower(err.Error()), "non-fast-forward")
} Try / catch
if err := versioncontrolops.Push(ctx, db, remote, branch, user); err != nil {
if isNonFastForward(err) {
// decide deliberately: fetch+merge, or explicit ForcePush
return fmt.Errorf("push to %s/%s diverged: %w", remote, branch, err)
}
return fmt.Errorf("push to %s/%s: %w", remote, branch, err)
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- dolt push failed: %w Output: %s
- fetch from %s: %w
- %w Output: %s
- failed to push to peer %s: %w
- dolt clone %s: %w
AI-assisted analysis of gastownhall/beads@71377f2769 (2026-08-30).
Data as JSON: /api/errors/daf931679c7bb7c9.
Report an issue: GitHub.