{"record":{"id":"c86b6996d5de5b3e","repo":"gastownhall/beads","slug":"dolt-push-failed-w-output-s","errorCode":null,"errorMessage":"dolt push failed: %w\nOutput: %s","messagePattern":"dolt push failed: %w\nOutput: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/remotecache/cache.go","lineNumber":151,"sourceCode":"\treturn entry, nil\n}\n\n// Push pushes local commits in the cached clone back to the remote.\nfunc (c *Cache) Push(ctx context.Context, remoteURL string) error {\n\ttarget := c.cloneTarget(remoteURL)\n\tif !c.doltExists(target) {\n\t\treturn fmt.Errorf(\"no cached clone for %s\", remoteURL)\n\t}\n\n\tlock, err := c.acquireLock(ctx, remoteURL)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to acquire cache lock: %w\", err)\n\t}\n\tdefer c.releaseLock(lock)\n\n\tcmd := doltCmd(ctx, target, \"push\", \"origin\", \"main\")\n\tif output, err := cmd.CombinedOutput(); err != nil {\n\t\treturn fmt.Errorf(\"dolt push failed: %w\\nOutput: %s\", err, output)\n\t}\n\n\t// Update push timestamp\n\tmeta := c.readMeta(remoteURL)\n\tmeta.LastPush = time.Now().UnixNano()\n\tc.writeMeta(remoteURL, meta)\n\n\treturn nil\n}\n\n// OpenStore opens a DoltStorage from the cached clone using the provided\n// StoreOpener. The cache entry directory is used as the beads directory.\n// The caller is responsible for calling Close() on the returned store.\n//\n// Note: OpenStore does not acquire a cache lock. The caller must ensure\n// no concurrent Ensure() or Push() is running against the same remoteURL,\n// as those modify the underlying dolt database. This is safe for single-\n// process CLI use but not for concurrent multi-process access.","sourceCodeStart":133,"sourceCodeEnd":169,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/remotecache/cache.go#L133-L169","documentation":"Push() shells out to `dolt push origin main` inside the cached clone and wraps the command's error plus its combined stdout/stderr output. This means dolt itself rejected the push — the local clone could not be pushed to the remote. The wrapped Output text carries dolt's own diagnostic (auth failure, non-fast-forward, network error, etc.).","triggerScenarios":"Cache.Push(ctx, remoteURL) runs dolt push and it exits non-zero: remote is ahead (non-fast-forward), missing/invalid credentials (DOLT_REMOTE_USER/DOLT_REMOTE_PASSWORD/dolt creds), unreachable remote, remote branch protection, or a corrupted local clone.","commonSituations":"Expired Dolthub credentials; pushing without pulling first so origin/main has commits the clone lacks; offline or VPN-required networks; remote repo deleted or renamed; wrong URL typed in config.","solutions":["Read the wrapped `Output:` section — dolt's message identifies the actual cause (auth, non-fast-forward, network).","If non-fast-forward: run Ensure() first to pull, merge fast-forward, then Push().","Refresh credentials: set DOLT_REMOTE_USER/DOLT_REMOTE_PASSWORD or run `dolt creds use`/`dolt login`.","Verify the remote is reachable and correct: `dolt ls-remote <url>` or check the URL in your bd config.","If the clone is corrupted, `Evict(remoteURL)` and Ensure() to re-clone."],"exampleFix":"// before: push without ensuring the clone is fresh\nif err := cache.Push(ctx, remoteURL); err != nil { return err }\n// after: pull first, then push\nif _, err := cache.Ensure(ctx, remoteURL); err != nil { return err }\nif err := cache.Push(ctx, remoteURL); err != nil { return err }","handlingStrategy":"try-catch","validationCode":"if _, err := exec.LookPath(\"dolt\"); err != nil {\n    return fmt.Errorf(\"dolt CLI required\")\n}\nif err := remotecache.ValidateRemoteURL(remoteURL); err != nil {\n    return err\n}","typeGuard":null,"tryCatchPattern":"if err := cache.Push(ctx, url); err != nil {\n    var doltOutput string\n    if i := strings.Index(err.Error(), \"Output:\"); i >= 0 {\n        doltOutput = err.Error()[i:]\n    }\n    switch {\n    case strings.Contains(doltOutput, \"unexpected client error: unauthorized\"),\n         strings.Contains(doltOutput, \"authentication\"):\n        return fmt.Errorf(\"refresh dolt credentials (DOLT_REMOTE_USER/DOLT_REMOTE_PASSWORD or dolt creds): %w\", err)\n    case strings.Contains(doltOutput, \"Non-Fast-Forward\"):\n        if _, err := cache.Ensure(ctx, url); err != nil { return err }\n        return cache.Push(ctx, url)\n    }\n    return err\n}","preventionTips":["Always Ensure() (pull) before Push() to avoid non-fast-forward rejections.","Keep Dolt credentials current (dolt creds / env vars); check expiry in CI.","Verify remote reachability (VPN/proxy) before long sync batches.","Check dolt's wrapped Output text first — it names the real cause."],"tags":["go","dolt","push","network","authentication"],"backgroundTag":"dolt-push-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}