Skip to content

Fix repo sync: advance the bare clone, and name an out-of-space failure - #2

Merged
dougrathbone merged 2 commits into
masterfrom
dougrathbone/repo-sync-git-errors-0332
Aug 31, 2026
Merged

dougrathbone merged 2 commits into
masterfrom
dougrathbone/repo-sync-git-errors-0332

Conversation

@dougrathbone

Copy link
Copy Markdown
Owner

The reported symptom was this on the repository picker in the agent editor:

Error: git remote failed (exit 128): error: failed to write new configuration file
/data/repos/9f7404af-a623-4d35-9a59-267aeb88389f/config.lock
fatal: could not set 'remote.origin.url' to 'https://***@github.com/heydovetail/platform.git'

Investigating it turned up two separate problems in fetchRepo.

1. That message means the data volume is full

git remote set-url writes the config through config.lock. git reports a
failed write via its write_error() helper, which formats with error()
rather than error_errno() — so the errno is dropped and nothing in the text
says "No space left on device" for isDiskFullError to match on. Reproduced on
a full tmpfs, which prints exactly the message above, byte for byte.

The message is only reachable after git created and opened the lock file, so
it is neither a permission problem nor a stale lock (both fail earlier with
"could not lock config file"). The write itself failed: the volume is full or
over quota.

So: recognise it, and translate a disk-full clone/fetch failure into the
actionable message the worktree path already used — "Not enough disk space to
sync this repository. Free space on the Conduit server or increase its data
volume, then retry." Those failures now report as a message rather than an
exception, because the raw git text embeds the clone path and was splintering
one operational problem into a separate Sentry issue per repository (the raw
text is kept as context).

2. Sync was never actually advancing the clone

git clone --bare creates no remote.origin.fetch refspec — per git's own
documentation it makes "neither remote-tracking branches nor the related
configuration variables". The sync's git fetch --prune origin therefore had
no refspec to apply: it downloaded objects, wrote FETCH_HEAD, and left
refs/heads/<branch> pointing wherever the original clone left it.

Every cycle reported success and updated "Synced 2 minutes ago" while the clone
never moved, so every run worktreed the repository as it stood when it was
first added.

The fix fetches an explicit forced refspec for the repo's default branch.
--prune is dropped: with an explicit refspec it would delete the clone's only
branch as soon as that branch disappears upstream, leaving nothing to worktree
from; without it that case fails loudly and the last good ref survives.

The credential also now travels as the fetch URL instead of being written to
the clone's config first. That write was the only reason a routine sync touched
<clone>/config — the very step that fails first on a full volume, aborting
the sync before git had even tried to fetch (an up-to-date repo needs no space
at all). It also contends with the per-run configureWorktreeGit writes, which
land in that same shared config file. The stored URL is still refreshed for
git lfs fetch, but best-effort and only when the credential changed.

Worth noting a dead end here: -c remote.origin.url=… does not work for
this. url is a multi-valued remote key, so a command-line value is appended
to the stored list rather than replacing it, and git still dials the stored URL
first. Verified — it fetched a deliberately bogus stored URL and failed.

Verification

  • New unit tests for the refspec, the credential path, the best-effort config
    refresh, the new disk-full detection, and the actionable syncError.
  • Against real git: cloned a repo, committed upstream, ran fetchRepo, and
    confirmed the clone advanced and a fresh worktree contains the new content.
    The old code left the clone at the original commit.
  • Against a real full filesystem: fetchRepo on a 100%-full tmpfs now yields
    "Not enough disk space to sync this repository…" instead of the config.lock
    dump.
  • Full suite (600 tests), both type-check projects, and npm run build pass.

Follow-up, not fixed here

configureWorktreeGit runs git config user.name and git remote set-url with
the worktree as cwd, but a linked worktree shares the bare clone's config — so
those per-run writes land in <clone>/config. Two concurrent runs of the same
repo therefore overwrite each other's committer identity, and one run's token
becomes the other's origin URL. Fixing it properly means per-worktree config
or moving the identity/credential out of git config entirely, which is a larger
change than this one.

Open in Web Open in Cursor 

cursoragent and others added 2 commits August 31, 2026 12:56
`git clone --bare` creates no `remote.origin.fetch` refspec, so the sync's
`git fetch --prune origin` had nothing to apply: it downloaded objects, wrote
FETCH_HEAD, and left `refs/heads/<branch>` pointing wherever the original clone
left it. Sync reported success on every cycle while the clone never moved, so
every run worktreed the repository as it stood when it was first added.

Fetch an explicit forced refspec for the repo's default branch, which is what
actually advances the branch. No `--prune`: with an explicit refspec it would
delete the clone's only branch as soon as that branch disappears upstream,
leaving nothing to worktree from.

The credential now travels as the fetch URL rather than being written to the
clone's config first. That write was the only reason a routine sync touched
`<clone>/config`, and it is the step that breaks first when the data volume
fills — git rewrites the whole file through `config.lock`, so a failed write
aborted the sync before git had even tried to fetch. The stored URL is still
refreshed for `git lfs fetch`, but best-effort and only when it changed.

Co-authored-by: Doug Rathbone <dougrathbone@users.noreply.github.com>
git's config writer reports a failed write through `write_error()`, which
formats with `error()` rather than `error_errno()`. The errno is dropped, so an
out-of-space config write arrives with no "No space left on device" for
`isDiskFullError` to match, and the repository owner saw the raw dump instead:

  git remote failed (exit 128): error: failed to write new configuration file
  /data/repos/<id>/config.lock
  fatal: could not set 'remote.origin.url' to 'https://***@github.com/…'

That message is only reachable after git created and opened the lock file, so
it is neither a permission problem nor a stale lock (both fail earlier, with
"could not lock config file") — the write itself failed, which in practice
means the volume is full or over quota.

Recognise it, and translate a disk-full clone/fetch failure into the actionable
message the worktree path already used, so the repositories UI says what to do.
Such failures report as a message rather than an exception: the raw text embeds
the clone path, which splintered one operational problem into a separate issue
per repository.

Co-authored-by: Doug Rathbone <dougrathbone@users.noreply.github.com>
@dougrathbone
dougrathbone merged commit 198a5bc into master Aug 31, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants