You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Placeholder-scan tests race against git housekeeping in .git/objects #1815
The placeholder-scan tests walk the whole scaffolded workspace with a lazy rglob("*"), .git/ included, and read_text() every file. A loose git object listed by the walk can be gone by the time it is opened, crashing the test with FileNotFoundError (only UnicodeDecodeError is caught).
Seen once on PR #1812 (run 37247340361, job Integration Tests, 89 passed / 1 failed); passed on re-run:
tests/test_install_script.py::TestInstallScriptIntegration::test_install_replaces_org_name_placeholder
FileNotFoundError: [Errno 2] No such file or directory: '.../tests/tmp/Install-Test-Project-k8aucshk/.git/objects/c5/1db2915d65b7336def5d6d0558455933cd8eef'
Probable (unverified) mechanism: install.sh runs git add -A && git commit on the host, and git's detached auto-maintenance packs/prunes loose objects while the test is walking.
Scanning .git/objects is meaningless anyway: objects are zlib-compressed and can never contain a placeholder.
Steps to Reproduce
Nondeterministic. Run the Integration Tests CI job; rare.
Expected Behavior
Placeholder scans only cover scaffolded files and are immune to concurrent git housekeeping.
Actual Behavior
Intermittent FileNotFoundError on a .git/objects/ path fails Integration Tests.
Possible Solution
tests/test_install_script.py:199 (test_install_replaces_placeholder) and :234 (test_install_replaces_org_name_placeholder): skip paths under .git/, materialize the file list before reading.
:234 duplicates the parametrized {{ORG_NAME}} case at :199 — consider removing it.
tests/test_integration.py:590 (test_placeholders_replaced): same lazy-walk pattern; add .git to excluded_paths.
Test-only change; TDD red phase not applicable (nondeterministic race).
The deleter is git's own background auto-maintenance, triggered by the scaffold commit in install.sh.
install.sh (setup_git_repo) runs git commit for the initial scaffold. Every git commit spawns git maintenance run --auto --quiet --detach (confirmed with GIT_TRACE on git 2.55.0, the version on the ubuntu-26.04 runner).
Since git 2.54 the default maintenance strategy is geometric (2.54.0 release notes). Its geometric-repack task fires at maintenance.geometric-repack.auto = 100 loose objects. Like gc --auto, the auto check estimates the count by sampling .git/objects/17/ × 256. So 1 object in that bucket means "not needed", and 2 or more means "repack".
A fresh scaffold commit leaves ~161 loose objects. Whether two of them land in 17/ depends on content. The commit object's hash embeds a timestamp, so it varies per run, which is why the failure is rare.
When the repack triggers, it packs every loose object and deletes all the loose files ~200–400 ms after the commit. The class fixture returns right after install.sh, and the placeholder walks are the first tests in the class. A lazy rglob("*") that walks into .git/objects/ can therefore list a file that is gone by the time read_text() opens it, which raises FileNotFoundError.
Evidence
Local install.sh run, then the scaffold commit replayed with git 2.55.0 and a minimal config:
GIT_TRACE shows git maintenance run --auto --quiet --detach started by commit.
Scaffold as-is (1 object in objects/17/): maintenance is-needed --auto says not needed, and the 161 loose objects stay put.
The same scaffold plus one extra file whose blob hashes into 17/: 162 loose / 0 packs → 0 loose / 1 pack within 400 ms of the commit.
The vanished object c51db29… is an ordinary scaffold blob (.devcontainer/scripts/copy-host-user-conf.sh). It existed after the commit and was removed by the repack.
The apparent 10.5 s runtime of the failed test is an artifact. -x runs the session devcontainer teardown (podman rm -f) before the FAILED line is printed. The walk itself takes ~15 ms, the same as the three walks just before it.
Ruled out
Background processes from install.sh or the devcontainer lifecycle scripts: there are none.
The session devcontainer's tests/ bind mount: nothing in the container touches tests/tmp.
Parallel pytest: the job runs serially.
Impact
Tests only. The background repack is correct and desirable in a real consumer repo, so install.sh is unchanged.
Fix
One shared test helper returns the scaffold's regular files as a materialized, sorted list, excluding .git/. Git internals can never contain a placeholder.
The helper is used by test_install_replaces_placeholder (tests/test_install_script.py) and test_placeholders_replaced (tests/test_integration.py). The integration workspace is also a git repo with commits, so it is exposed to the same race.
test_install_replaces_org_name_placeholder is deleted. It duplicates the parametrized {{ORG_NAME}} case.
Not done: disabling maintenance in the fixtures. Excluding .git removes the race, and fixtures should keep real-install behaviour.
Activity
c-vigo commentedon Oct 5, 2026
Root cause analysis
The deleter is git's own background auto-maintenance, triggered by the scaffold commit in
install.sh.install.sh(setup_git_repo) runsgit commitfor the initial scaffold. Everygit commitspawnsgit maintenance run --auto --quiet --detach(confirmed withGIT_TRACEon git 2.55.0, the version on theubuntu-26.04runner).geometric(2.54.0 release notes). Itsgeometric-repacktask fires atmaintenance.geometric-repack.auto= 100 loose objects. Likegc --auto, the auto check estimates the count by sampling.git/objects/17/× 256. So 1 object in that bucket means "not needed", and 2 or more means "repack".17/depends on content. The commit object's hash embeds a timestamp, so it varies per run, which is why the failure is rare.install.sh, and the placeholder walks are the first tests in the class. A lazyrglob("*")that walks into.git/objects/can therefore list a file that is gone by the timeread_text()opens it, which raisesFileNotFoundError.Evidence
install.shrun, then the scaffold commit replayed with git 2.55.0 and a minimal config:GIT_TRACEshowsgit maintenance run --auto --quiet --detachstarted bycommit.objects/17/):maintenance is-needed --autosays not needed, and the 161 loose objects stay put.17/: 162 loose / 0 packs → 0 loose / 1 pack within 400 ms of the commit.c51db29…is an ordinary scaffold blob (.devcontainer/scripts/copy-host-user-conf.sh). It existed after the commit and was removed by the repack.-xruns the session devcontainer teardown (podman rm -f) before the FAILED line is printed. The walk itself takes ~15 ms, the same as the three walks just before it.Ruled out
install.shor the devcontainer lifecycle scripts: there are none.tests/bind mount: nothing in the container touchestests/tmp.Impact
Tests only. The background repack is correct and desirable in a real consumer repo, so
install.shis unchanged.Fix
.git/. Git internals can never contain a placeholder.test_install_replaces_placeholder(tests/test_install_script.py) andtest_placeholders_replaced(tests/test_integration.py). The integration workspace is also a git repo with commits, so it is exposed to the same race.test_install_replaces_org_name_placeholderis deleted. It duplicates the parametrized{{ORG_NAME}}case..gitremoves the race, and fixtures should keep real-install behaviour.test: expect the placeholder-scan walk to skip .git
fix(test): skip .git in placeholder scans to dodge background repack
fix(test): skip .git in placeholder scans to dodge background repack (#…
c-vigo commentedon Oct 5, 2026
Fixed by #1816 (merged to
devas 3aa23c6); reachesmainwith the next release train.test: prevent fixture maintenance races during scaffold drift (#1941)