Skip to content

Workspace git clone leaves an empty repo but reports WorkspaceReady/SetupComplete #347

Closed

Description

@naeemarsalan

Summary

A Workspace with a git entry reports WorkspaceReady: True / SetupComplete, and the task starts, with an empty repository in the workspace path — git init has run, origin is configured, and FETCH_HEAD is 0 bytes. No commits, no refs, no files.

A manual git clone of the identical URL, from inside that same sandbox, succeeds.

AX v0.3.0 (d8ed0fe), Agent Substrate on a 2-node kind cluster.

Manifests

apiVersion: ax.io/v1alpha1
kind: Workspace
metadata:
  name: ambient-workspace
  atespace: default
spec:
  git:
    - name: origin
      repo: "https://git.arsalan.io/anaeem/ambient-platform.git"
      branch: "master"
---
apiVersion: ax.io/v1alpha1
kind: Task
metadata:
  name: egr-c
  atespace: default
spec:
  image: "<our image>"
  command: ["bash","-lc","sleep 3600"]
  workspaces:
    - name: ambient-workspace
      path: "/workspace/repo"
  gateway: {name: ambient-gateway}     # egress allowlist ["*"]
  debug: true

The repo is public; git ls-remote succeeds unauthenticated and returns refs/heads/master, so branch: master is correct.

What the task reports

NAME    ATESPACE   PHASE     ACTOR   WORKER-IP
egr-c   default    Running   egr-c   10.244.1.59

Conditions:
  WorkspaceReady  True   SetupComplete   Workspace setup completed at 10.244.1.59
  Ready           True   TaskRunning     Task is running and its workspace is ready

Controller log: task successfully reconciled and running ... workspaceReady=true phase=Running

What is actually there

$ find /workspace/repo/ambient-platform -type f -not -path "*/.git/*" | wc -l
0

$ git -C /workspace/repo/ambient-platform log --oneline -1
fatal: your current branch 'master' does not have any commits yet

$ git -C /workspace/repo/ambient-platform status
On branch master
No commits yet

$ ls -la /workspace/repo/ambient-platform/.git/
-rw-r--r-- 1 root root    0 Sep 21 00:33 FETCH_HEAD      <-- zero bytes
-rw-r--r-- 1 root root  213 Sep 21 00:33 config
drwxr-xr-x 2 root root    6 Sep 21 00:33 branches
drwxr-xr-x 4 root root   30 Sep 21 00:33 objects
drwxr-xr-x 4 root root   31 Sep 21 00:33 refs         <-- empty

$ cat /workspace/repo/ambient-platform/.git/config
[core]
	repositoryformatversion = 0
	...
[remote "origin"]
	url = https://git.arsalan.io/anaeem/ambient-platform.git
	fetch = +refs/heads/*:refs/remotes/origin/*

So git init and git remote add ran; the fetch produced nothing and whatever it returned was not surfaced.

It is not the network, and not credentials

From inside the same running sandbox, at the same moment:

$ curl -o /dev/null -w "%{http_code}" https://git.arsalan.io/anaeem/ambient-platform
200

$ git clone -q https://git.arsalan.io/anaeem/ambient-platform.git /tmp/manual
$ find /tmp/manual -type f -not -path "*/.git/*" | wc -l
105

Reproduced with the gateway egress allowlist set to ["*"] and with a narrow allowlist that includes the forge's address. Same empty result both times.

Why this one is worth fixing loudly

An empty workspace that reports SetupComplete is worse than a failed one. The agent starts, finds no files, and does something reasonable-looking with nothing — in our case a coding agent would have begun work in an empty directory believing it had the repository. The failure surfaces much later, as strange output rather than as a setup error.

A non-zero fetch should fail WorkspaceReady with the git error in the condition message. Even SetupComplete with a warning would be enough to make it visible.

Happy to test a patch, run it with verbose git tracing, or gather anything else from this cluster.

Activity

  1. arbazkhan971 commented on Sep 22, 2026

    @arbazkhan971

    Fix ready: implemented on my fork (branch fix/347-workspace-git-failure, regression test included, make test green) and ready to PR — but this repo's collaborators_only PR creation policy rejects PRs from non-collaborators (see #358), so I cannot open it. If PR creation opens for external contributors, I will open the PR immediately. Happy to adjust scope per maintainer feedback.

  2. gambtho commented on Oct 1, 2026

    @gambtho

    Inline workspace files on main (ac23328) have the same problem: writeFiles in internal/workspace/setup.go logs write errors instead of returning them, so setup can complete with files missing. Found reading the code, not reproduced.

  3. fujiezee commented on Oct 1, 2026

    @fujiezee

    The fixes described here and in the comments are about surfacing the error from one particular step: the fetch, or the inline file writes. One thing that might be worth adding alongside them is a check on the outcome rather than on each step.

    At the end of setup, it could compare what is in the workspace with what the spec declared. For a git entry, that might be that the requested branch resolves to a HEAD commit. For inline files, that every declared file exists. Recording the resolved commit SHA in the condition message would also show what the workspace started from. The empty repository in the report and the missing inline files in the last comment would then both fail at that one point, whichever step dropped the error.

    This should be compatible with failing on a non-zero fetch, since it only catches what that check misses. It would also make SetupComplete mean "the workspace matches the spec" rather than "nothing reported an error".

    I haven't read the setup code beyond what is quoted in the thread, so the right place for such a check may differ.

  4. yjjnls commented on Nov 19, 2026

    @yjjnls

    Friendly heads-up: this looks fixed on main — a failed git clone no longer reports setup success.

    • cloneRepos errors now abort setup (internal/workspace/setup.go:119-123, changed in dd66b7f / workspace: align v1alpha1 schema, enforce immutability, and materialize spec.setup #580) instead of the previous warn-and-continue path, and the failed maiden run omits the marker so the next start retries (contract documented at setup.go:78-79).
    • The runner returns the error without marking the workspace ready (runner/runner.go:171-173), so a task can no longer start against an empty repo reporting WorkspaceReady: True.
    • There is a regression test covering both halves — error returned, marker omitted on a failed clone (TestSetupWorkspace_GitError, internal/workspace/setup_test.go:213-242).

    The inline-files gap from @gambtho's comment is covered by the same change: writeFiles returns write errors (setup.go:279-301) and its caller propagates them (setup.go:125-127).

    With the original report and the follow-up both addressed on main, this issue could be closed — just flagging so the credit for the report and @arbazkhan971's fork fix doesn't get lost.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions