{"record":{"id":"0dfe051cfa539344","repo":"gitbutlerapp/gitbutler","slug":"push-failed-after-max-retries-attempts","errorCode":null,"errorMessage":"push failed after {MAX_RETRIES} attempts","messagePattern":"push failed after (.+?) attempts","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but-agentlog/src/gitmeta/write.rs","lineNumber":301,"sourceCode":"        Err(git_meta_lib::Error::GitCommand(message))\n            if message.contains(\"couldn't find remote ref\") => {}\n        Err(err) => return Err(err).context(\"failed to pull GitMeta metadata\"),\n    }\n\n    let mut attempts = 0;\n    loop {\n        attempts += 1;\n        let output = gitmeta\n            .push_once(None)\n            .context(\"failed to push GitMeta metadata\")?;\n        if output.success {\n            return Ok(());\n        }\n        if !output.non_fast_forward {\n            bail!(\"push failed\");\n        }\n        if attempts >= MAX_RETRIES {\n            bail!(\"push failed after {MAX_RETRIES} attempts\");\n        }\n        gitmeta\n            .resolve_push_conflict(None)\n            .context(\"failed to resolve GitMeta push conflict\")?;\n    }\n}\n\nfn stored_text(kind: RecordKind, text: Option<&str>) -> Option<String> {\n    let text = text?;\n    Some(match kind {\n        RecordKind::ToolResult => redact_text(cap_tool_result_text(text).as_ref()),\n        _ => redact_text(text),\n    })\n}\n\nfn file_path_hashes_for_record(\n    repo_root: &Path,\n    tool_kind: Option<ToolKind>,","sourceCodeStart":283,"sourceCodeEnd":319,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but-agentlog/src/gitmeta/write.rs#L283-L319","documentation":"sync_metadata retries pushing GitMeta metadata after resolving non-fast-forward conflicts, up to MAX_RETRIES. If after MAX_RETRIES attempts the push still reports non-fast-forward failure, it gives up with 'push failed after {MAX_RETRIES} attempts', meaning the remote kept advancing (or conflicts could not be resolved) faster than local pushes landed.","triggerScenarios":"Calling sync_metadata (via run_from_dir) when repeated cycles of push_once + resolve_push_conflict all yield non_fast_forward failures for MAX_RETRIES consecutive attempts.","commonSituations":"A very active remote where other writers continuously push GitMeta updates; a persistent rebasing/resolution loop caused by conflicting writer versions; a stuck or failing resolve_push_conflict that never produces a pushable ref.","solutions":["Re-run the sync later — a transient contention burst usually resolves once other writers pause.","Fetch the GitMeta ref and inspect what keeps advancing; identify competing writers or a broken resolve loop.","Manually integrate the remote GitMeta state locally (fetch, rebase/merge the GitMeta branch) and push once.","Check that all writers run a compatible agentlog version so conflict resolution converges instead of looping."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// ensure the local GitMeta ref is up to date before syncing\ngit fetch <remote> <gitmeta_ref> && git log --oneline HEAD..<remote>/<gitmeta_ref> | head -n 5","typeGuard":null,"tryCatchPattern":"match sync_metadata(...).context(\"syncing GitMeta\") {\n    Err(e) if e.to_string().contains(\"push failed after\") => {\n        // contention loop: pause, fetch and integrate remote state, then retry later\n        std::thread::sleep(BACKOFF);\n        gitmeta.fetch_and_rebase()?;\n        sync_metadata(...)?;\n    }\n    other => other?,\n}","preventionTips":["Avoid many writers pushing GitMeta concurrently; batch or serialize syncs.","Verify resolve_push_conflict is actually converging (log attempts and remote refs).","Keep all writers on the same agentlog version so conflict resolution is deterministic."],"tags":["git","push","conflict","retry-exhausted"],"backgroundTag":"git-command-failed","analyzedSha":"58e5313667b857ef39a730e380af31816a7b1768","analyzedAt":"2026-09-18T06:50:32.052Z","contentChangedAt":"2026-09-18T06:50:32.052Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}