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
[BUG] Template-tree walks silently no-op when TEMPLATE_DIR carries a trailing slash #1703
Three template-tree walks in assets/init-workspace.sh derive a workspace path with rel="${src_path#"$src_dir"/}" after find -L "$src_dir" …:
sweep_scaffold_writable (the chmod u+w sweep)
the --preview report walk
the +x sweep near the end of the run
If $src_dir (TEMPLATE_DIR or the smoke overlay dir) carries a trailing slash, GNU find normalises its output to /…/workspace/a.txt, the prefix /…/workspace// never strips, rel stays absolute, the mapped destination never exists, and the walk silently does nothing: exit 0, no warning.
The #1693 substitution routine had the same latent bug; it was caught in review and fixed there with a one-line local src_dir="${1%/}" plus a trailing-slash BATS test. The other three walks still have it. No in-repo caller passes a trailing slash today (only init-workspace.sh reads TEMPLATE_DIR; BATS passes none), so this is latent, but the failure mode is silent.
Steps to Reproduce
TEMPLATE_DIR="$PWD/assets/workspace/" (trailing slash), scaffold with the BATS helper env into an empty dir
Make a template-shipped destination read-only before an upgrade, or inspect --preview output
Expected Behavior
Each walk strips a trailing slash from its source dir (${1%/}) and behaves identically with or without it; one BATS test per walk pins it.
Actual Behavior
The walk maps every file to a non-existent absolute-under-absolute path and skips it.
Environment
OS: any
Container Runtime: n/a
Image Version/Tag: dev
Architecture: any
Additional Context
Found by the #1693 review. The cleanest fix is the shared "template-shipped candidates" emitter proposed in #1700, which would normalise the source dir once for every consumer of the walk.
Possible Solution
Normalise once at the top of each walk (src_dir="${src_dir%/}"), or factor the walk into the shared emitter from #1700 and normalise there.
Triage 2026-09-25: confirmed in all three walks; one-line root fix
Verified in a scratch dir: find -L /a/src/ -mindepth 1 -type f prints /a/src/a.txt, so ${p#"/a/src/"/} (double slash) never strips, rel stays absolute, dest="$WORKSPACE_DIR//a/src/a.txt" never exists, and each walk exits 0 having done nothing.
The preview walk (~L2795) and the +x sweep (~L3739) read the global TEMPLATE_DIR directly, and sweep_scaffold_writable is called with it (~L3222/L3225), so normalising once at the single assignment site — TEMPLATE_DIR="${TEMPLATE_DIR%/}" right after L54 — fixes all three plus any future walk; dirname at ~L1555 and the rsync "$TEMPLATE_DIR/" source are unaffected. The shared emitter from #1700 additionally normalises its own src_dir argument (the smoke overlay path is passed explicitly).
Disposition: implemented together with #1700 in one PR. Red test: TEMPLATE_DIR=".../assets/workspace/" (trailing slash) → a read-only template-shipped file becomes writable, a template *.sh is +x, and --preview lists non-empty ADDED/OVERWRITTEN — mirrors the #1693 test at init-workspace.bats ("a TEMPLATE_DIR with a trailing slash still substitutes placeholders").
Fixed in #1715, merged to dev (ecb8f8d): TEMPLATE_DIR is normalised once at its only assignment, and the shared emitter normalises its own source argument; a BATS test pins all three walks against a trailing slash.
Activity
c-vigo commentedon Sep 25, 2026
Triage 2026-09-25: confirmed in all three walks; one-line root fix
Verified in a scratch dir:
find -L /a/src/ -mindepth 1 -type fprints/a/src/a.txt, so${p#"/a/src/"/}(double slash) never strips,relstays absolute,dest="$WORKSPACE_DIR//a/src/a.txt"never exists, and each walk exits 0 having done nothing.The preview walk (~L2795) and the
+xsweep (~L3739) read the globalTEMPLATE_DIRdirectly, andsweep_scaffold_writableis called with it (~L3222/L3225), so normalising once at the single assignment site —TEMPLATE_DIR="${TEMPLATE_DIR%/}"right after L54 — fixes all three plus any future walk;dirnameat ~L1555 and the rsync"$TEMPLATE_DIR/"source are unaffected. The shared emitter from #1700 additionally normalises its ownsrc_dirargument (the smoke overlay path is passed explicitly).Disposition: implemented together with #1700 in one PR. Red test:
TEMPLATE_DIR=".../assets/workspace/"(trailing slash) → a read-only template-shipped file becomes writable, a template*.shis+x, and--previewlists non-empty ADDED/OVERWRITTEN — mirrors the #1693 test atinit-workspace.bats("a TEMPLATE_DIR with a trailing slash still substitutes placeholders").test(init): pin the writable sweep to the copy step's prunes
test(init): pin every template walk against a trailing TEMPLATE_DIR s…
fix(init): walk the template through one pruned candidate emitter
fix(init): prune the smoke overlay copy like the template copy
fix(init): walk the template through one pruned candidate emitter (#1715
c-vigo commentedon Sep 25, 2026
Fixed in #1715, merged to
dev(ecb8f8d):TEMPLATE_DIRis normalised once at its only assignment, and the shared emitter normalises its own source argument; a BATS test pins all three walks against a trailing slash.