Repository navigation
Description
What is the issue?
When GITHUB_REF is a refs/pull/... ref (i.e. a GitHub Actions pull_request build), Dagger's telemetry git-label collection runs git fetch --depth 1 inside the host working tree, which writes .git/shallow and turns the user's checkout into a shallow (depth-1) clone. This silently corrupts the repository: after it runs, git merge-base, git log, git describe, etc. no longer see history.
The offending code is engine/telemetry/labels.go:
// WithGitLabels(workdir)
if ref, ok := os.LookupEnv("GITHUB_REF"); ok {
if strings.HasPrefix(ref, "refs/pull/") {
refCommit, err := fetchRef(repo, workdir, "origin", ref) // runs in the host workdir
...
// fetchRef(...)
dest := fmt.Sprintf("refs/dagger/%s", target)
cmd := exec.Command("git", "fetch", "--depth", "1", remote, fmt.Sprintf("+%s:%s", src, dest))GIT_TRACE from a real GitHub Actions run, showing the fetch executing against the checkout's own .git:
git.c:502 trace: built-in: git fetch --depth 1 origin +refs/pull/946/head:refs/dagger/pull/946/head
setup: git_dir: .git
setup: worktree: /home/runner/work/<repo>/<repo>
setup: cwd: /home/runner/work/<repo>/<repo>
The destination is a scratch refs/dagger/... ref, but the fetch still runs in (and shallows) the host repository.
Impact
Dagger mutates/corrupts the user's source checkout as a side effect of telemetry. Any tool run afterwards that needs history breaks. In our case it surfaced as commitlint --from=origin/main failing for every pull request with Cannot find merge-base between 'origin/main' and 'HEAD', because the checkout had been reduced to a single commit. It would equally break git describe, changelog generation, coverage diffs, etc. It also took a long investigation to trace, since the corruption happens out-of-band from the failing tool.
Reproduction
In a clone of any GitHub repo that has PRs (history intact, not shallow):
git clone https://github.com/dagger/dagger /tmp/r && cd /tmp/r
git rev-list --count HEAD # e.g. 50000+
test -f .git/shallow && echo shallow || echo full # -> full
# Simulate a GitHub Actions PR build (GITHUB_REF set to a refs/pull/* ref):
GITHUB_REF=refs/pull/1/head dagger core container \
from --address=alpine/git \
with-mounted-directory --path=/src --source=. \
with-exec --use-entrypoint=false --args=true \
stdout
test -f .git/shallow && echo "SHALLOW (corrupted)" || echo full # -> SHALLOW (corrupted)
cat .git/shallow # the grafted commitReproduced with engine/CLI v0.21.4 both on GitHub-hosted ubuntu-latest and locally on Linux.
Expected behavior
Computing telemetry git labels must never mutate the user's working tree. The ref resolution should fetch into an isolated GIT_DIR (or a temp clone), or resolve the commit read-only, and must not pass --depth 1 to a fetch that targets the user's repository.
Workaround
Unset GITHUB_REF for the affected invocations (GITHUB_REF= dagger ...), which makes WithGitLabels skip the fetch.
I searched open/closed issues and didn't find an existing report for this.
Activity
ci: stop Dagger from shallow-cloning the working tree (#947)
fix(telemetry): don't shallow-clone the user's repo for git labels
fix(telemetry): don't shallow-clone the user's repo for git labels
fix(telemetry): don't shallow-clone the user's repo for git labels (#…
fix(telemetry): don't shallow-clone the user's repo for git labels (d…