Skip to content

adopt-project.py check passes a source whose tree holds a symlink whose target begins with a NUL byte (\0spec.md, a 120000 blob of size 8), so with symlinks on execute creates both leg repositories and then fails cloning the source, exit 2 with nothing on stderr, and #303's plan-empty-symlink, which tests the blob's size, does not find it #388

Closed

Description

@brettheap

Lane: openreposhape-5 (openRepoShape-5)

(lane openRepoShape-5, 2026-10-12T15:17:31Z)

Found by lane 5's review of fix/adopt-check-link-and-manifest at 69c54c9 (the fix for #303 and #305), its N6. Pre-existing on origin/main 161c6c9 (adopt-project.py is the same file at 0f67f7b), wherever the link sits in the tree. It is outside #303's literal scope, the empty blob, and the review's brief was to attack that fix. Not claimed.

What is wrong. #303's failure has a second spelling that its fix does not see. A tracked symlink whose blob begins with a NUL byte is not the empty blob (\0spec.md is 8 bytes), but Linux reads a leading NUL as an empty target, so symlink(2) fails with ENOENT exactly as it does for the empty blob. plan and check know a link only by its mode and its size (Source.tree, adopt-project.py:750-763, from git ls-tree -r -l) and never read its target, so check says plan ok. What execute does next is #303's:

The fix for #303 (head 69c54c9, not merged when this was filed) tests mode == SYMLINK_MODE and not size (empty_symlinks, adopt-project.py:2835-2839 there). A NUL-led target has size 1 or more, so on that head plan prints no NOTE, check exits 0 and execute fails as below.

SHAPE=<openRepoShape checkout>   # with git-filter-repo on PATH
# Every repository is local (--local-remote-dir), so no GitHub is reached. Keep the real `gh` out of reach anyway:
STUB=$(mktemp -d); printf '#!/bin/sh\nexit 1\n' > "$STUB/gh"; chmod +x "$STUB/gh"
export PATH="$STUB:$PATH" GH_TOKEN=bogus GH_CONFIG_DIR=$(mktemp -d)
export GIT_AUTHOR_NAME=T [email protected] GIT_COMMITTER_NAME=T [email protected]
LINK=docs/odd-link
TMP=$(mktemp -d)
git init -q -b main "$TMP/Thing" && cd "$TMP/Thing" || exit 1
mkdir src docs && printf 'print(1)\n' > src/app.py && printf '# Spec\n' > docs/spec.md
printf '# Thing\n' > README.md && git add -A
target=$(printf '\000spec.md' | git hash-object -w --stdin)
git update-index --add --cacheinfo "120000,$target,$LINK"   # a symlink whose target blob begins with NUL
git commit -qm init && git ls-tree -r -l HEAD -- "$LINK"
python3 "$SHAPE/adopt-project.py" plan --source "$TMP/Thing" --project Northwind --org testorg \
    --elected-by 'T H' --elected-on 2026-09-02 --out "$TMP/plan.yaml" >/dev/null
echo "plan exit $?"
python3 "$SHAPE/adopt-project.py" check --plan "$TMP/plan.yaml" | tail -1
python3 "$SHAPE/adopt-project.py" execute --plan "$TMP/plan.yaml" --yes \
    --local-remote-dir "$TMP/remotes" --work-dir "$TMP/work" > "$TMP/out" 2> "$TMP/err"
echo "execute exit $?; stdout:"
cat "$TMP/out"
echo "stderr: $(wc -c < "$TMP/err") bytes"
echo "leg repositories left: $(ls "$TMP/remotes" | tr '\n' ' ')"
git clone -q "$TMP/Thing" "$TMP/any-clone" 2> "$TMP/clone-err"; echo "a plain git clone of the source: exit $?"; head -2 "$TMP/clone-err"

Observed on origin/main 161c6c9 (Linux, git 2.43.0, Python 3.12.3; <T> is the temporary directory), and byte-identical on 69c54c9:

120000 blob da51ee712ecf519313363bb25342bb6dc80f4b8d       8	docs/odd-link
plan exit 0
plan ok
execute exit 2; stdout:
  topics skipped for local remotes

creating the leg repositories
  bare  <T>/remotes/Northwind-spec.git
  bare  <T>/remotes/Northwind-code.git
stderr: 0 bytes
leg repositories left: Northwind-code.git Northwind-spec.git
a plain git clone of the source: exit 128
error: unable to create symlink docs/odd-link: No such file or directory
fatal: unable to checkout working tree

With core.symlinks=false for the whole adoption, then a clone with symlinks on, as #303's second script does (the same source, then):

(  # the adoption runs where git checks a symlink out as a plain file
  export GIT_CONFIG_COUNT=1 GIT_CONFIG_KEY_0=core.symlinks GIT_CONFIG_VALUE_0=false
  python3 "$SHAPE/adopt-project.py" plan --source "$TMP/Thing" --project Northwind --org testorg \
      --elected-by 'T H' --elected-on 2026-09-02 --out "$TMP/plan.yaml" >/dev/null
  python3 "$SHAPE/adopt-project.py" check --plan "$TMP/plan.yaml" | tail -1
  python3 "$SHAPE/adopt-project.py" execute --plan "$TMP/plan.yaml" --yes \
      --local-remote-dir "$TMP/remotes" --work-dir "$TMP/work" > "$TMP/out" 2> "$TMP/err"
  echo "execute exit $?: $(grep '^adoption verified' "$TMP/out")"
)
echo "the spec leg holds: $(git -C "$TMP/remotes/Northwind-spec.git" ls-tree -r main -- "$LINK")"
git clone -q "$TMP/remotes/Northwind-spec.git" "$TMP/spec-clone" 2> "$TMP/spec-err"
echo "a clone of the spec leg: exit $?"; head -2 "$TMP/spec-err"
git -c protocol.file.allow=always clone -q --recurse-submodules -b adopt/three-repo-shape \
    "$TMP/Thing" "$TMP/assembly" > "$TMP/rec" 2>&1
echo "the assembly's recursive clone: exit $?"
grep -E '^(error|fatal)' "$TMP/rec" | sed -E "s#$TMP#<T>#g; s#'[0-9a-f]{40}'#'<spec commit>'#"

Observed on the same trees:

plan ok
execute exit 0: adoption verified: every source path is in exactly one place
the spec leg holds: 120000 blob da51ee712ecf519313363bb25342bb6dc80f4b8d	docs/odd-link
a clone of the spec leg: exit 128
error: unable to create symlink docs/odd-link: No such file or directory
fatal: unable to checkout working tree
the assembly's recursive clone: exit 1
error: unable to create symlink docs/odd-link: No such file or directory
fatal: Unable to checkout '<spec commit>' in submodule path 'spec'

Measured with the same script and other targets, symlinks on, on origin/main 161c6c9 and on 69c54c9 (the two agree on every row but the empty one):

the link's blob check execute a plain clone of the source
spec.md (control) plan ok exit 0, adoption verified exit 0
empty (#303) plan ok on main; plan-empty-symlink on 69c54c9 on main exit 2, 0 bytes of stderr, both legs left; on 69c54c9 refused, no leg exit 128, unable to create symlink ...: No such file or directory
\0spec.md plan ok exit 2, 0 bytes of stderr, both legs left exit 128, the same error
spec\0.md (a NUL later) plan ok exit 2, 431 bytes of stderr, both legs left (see below) exit 0
5000 a plan ok exit 2, 0 bytes of stderr, both legs left exit 128, unable to create symlink ...: File name too long

Why it matters.

Where (origin/main 161c6c9):

  • adopt-project.py:750-763, Source.tree: (path, mode, oid, size) per entry. It is the only thing plan and check read of a link.
  • adopt-project.py:3697, _refuse_what_check_finds, called at :4066: execute's refusal of what check finds, before _create_leg_remotes (:4077).
  • adopt-project.py:3327-3337, _extract_leg; :3836-3860, _build_the_legs; :4089-4092, cmd_execute returning 2 when it gets None.
  • On 69c54c9: adopt-project.py:2835-2839, empty_symlinks, the size test; :2884-2892, _source_path_findings, where the finding is composed.

What would fix it.

How to test. In tests/test_adopt_empty_symlinks.py on the #303 branch, whose put_link(repo, path, target: bytes) already builds a link in the index from bytes written to git hash-object on stdin, so it runs on Windows:

  • (a) a link at docs/odd-link with target b"\0spec.md": check exits 1 with a finding naming it, and execute refuses before any leg exists (the remotes directory holds none);
  • (b) the same with target b"spec.md" (control): check says plan ok;
  • (c) core.symlinks=false for the run changes neither answer.
    Reverting the fix fails (a). A test must pin neither spec\0.md nor a long target (see Not in this issue).

Not in this issue.

Related. #303, whose plan-empty-symlink this extends. #171 and PR #184: the silence. #183: lane 1's plan-root-symlink also reports an empty link kept at or above a shape path, and would meet a NUL-led one only through whatever reads its target. #168: execute refuses what check finds.

Activity

  1. added this to the v1.1.0 milestone on Oct 16, 2026
  2. brettheap commented on Oct 16, 2026

    @brettheap
    ContributorAuthor

    CLAIMED — lane openRepoShape-1, session 300f8f46-004a-4e72-8587-4f192be2e108@Eagle, 2026-10-16T11:31:43Z, for #388

    Logged in lanes/log/openRepoShape-1.md at 9d07ed25076645a0f809253a3110f0cc492ef640.

    The three reads (lane-collision-protocol Rule 1):

    1. existing `CLAIMED —` comments on opensoft/openRepoShape#388:
       none
    2. `gh pr list --repo opensoft/openRepoShape --state all --search "#388"`, kept where the row or its body names `#388`:
       none
    3. `git ls-remote --heads [email protected]:opensoft/openRepoShape` branches naming `388` as a whole token:
       none
    
  3. added 2 commits that reference this issue on Oct 17, 2026
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

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions