{"record":{"id":"49401da5c286dd6f","repo":"Graphify-Labs/graphify","slug":"error-could-not-read-ref-result-stderr-strip","errorCode":null,"errorMessage":"error: could not read {ref}: {result.stderr.strip()}","messagePattern":"error: could not read (.+?): (.+?)","errorType":"console","errorClass":"SystemExit","httpStatus":null,"severity":"error","filePath":"tools/skillgen/gen.py","lineNumber":751,"sourceCode":"        # An ATX heading is 1-6 '#' then a space then text.\n        if stripped.startswith(\"#\"):\n            hashes = len(stripped) - len(stripped.lstrip(\"#\"))\n            if 1 <= hashes <= 6 and stripped[hashes:hashes + 1] == \" \":\n                out.append(stripped.strip())\n    return out\n\n\ndef _git_show(ref: str) -> str:\n    \"\"\"Read a blob from git, normalised to LF.\"\"\"\n    result = subprocess.run(\n        [\"git\", \"show\", ref],\n        cwd=REPO_ROOT,\n        capture_output=True,\n        text=True,\n        encoding=\"utf-8\",\n    )\n    if result.returncode != 0:\n        raise SystemExit(f\"error: could not read {ref}: {result.stderr.strip()}\")\n    return result.stdout\n\n\ndef _v8_available() -> bool:\n    \"\"\"Whether origin/v8 is fetchable in this checkout.\n\n    The git-show validators (audit-coverage, monolith-roundtrip,\n    always-on-roundtrip) read blobs from origin/v8. CI's default shallow checkout\n    does not fetch that ref, so the validators set fetch-depth: 0 to fetch it.\n    This probe lets the CLI skip with a clear, actionable message (rather than\n    crash with a cryptic git error) when the ref is genuinely unreachable.\n    \"\"\"\n    result = subprocess.run(\n        [\"git\", \"rev-parse\", \"--verify\", \"--quiet\", \"origin/v8\"],\n        cwd=REPO_ROOT,\n        capture_output=True,\n        text=True,\n    )","sourceCodeStart":733,"sourceCodeEnd":769,"githubUrl":"https://github.com/Graphify-Labs/graphify/blob/7fe58b0b0f3873be9a21c30106b8b8527c353aa6/tools/skillgen/gen.py#L733-L769","documentation":"skillgen's _git_show() helper reads file blobs out of git history (git show <ref>) to power validators such as audit-coverage, monolith-roundtrip, and always-on-roundtrip, which compare rendered output against origin/v8 sources. If the git subprocess exits non-zero — bad ref, missing object, unreachable remote ref — the helper aborts with SystemExit embedding git's own stderr. The companion _v8_available() probe exists precisely because shallow CI checkouts often lack origin/v8.","triggerScenarios":"Invoking any git-show-based validator (audit-coverage, monolith-roundtrip, always-on-roundtrip) in a checkout where origin/v8 (or the referenced blob path) cannot be resolved: shallow clone with fetch-depth != 0, a clone where origin/v8 was never fetched, a ref typo, or a path that does not exist in that ref.","commonSituations":"GitHub Actions default shallow checkout (fetch-depth: 1) missing origin/v8; running validators in a worktree or partial clone without the ref; a local clone whose remote refs are stale after the v8 branch was force-pushed.","solutions":["Fetch the ref: `git fetch origin v8:refs/remotes/origin/v8` (or `git fetch --unshallow` in a shallow clone)","On GitHub Actions, set `fetch-depth: 0` on the actions/checkout step for the validator job","Run `git show <ref> --` manually with the failing ref to see git's underlying error and confirm the ref/path exists","If you cannot fetch the ref, rely on the CLI's skip path (_v8_available probe) instead of forcing the validator to run"],"exampleFix":"# before\n# .github/workflows/ci.yml\n- uses: actions/checkout@v4        # default fetch-depth: 1 → validators fail\n\n# after\n- uses: actions/checkout@v4\n  with:\n    fetch-depth: 0                 # origin/v8 fetchable → git-show validators run","handlingStrategy":"validation","validationCode":"import subprocess\n\ndef ref_readable(ref: str) -> bool:\n    return subprocess.run(\n        ['git', 'show', ref], capture_output=True\n    ).returncode == 0\n\nif not ref_readable('origin/v8:path/to/file'):\n    raise SystemExit('skip git-show validators: origin/v8 not fetched (use fetch-depth: 0 on CI)')","typeGuard":null,"tryCatchPattern":"from tools.skillgen.gen import _git_show\ntry:\n    blob = _git_show('origin/v8:skills/graphify/SKILL.md')\nexcept SystemExit as e:\n    raise SystemExit(f'validator input unavailable: {e}') from e","preventionTips":["Set fetch-depth: 0 on CI jobs that run the git-show validators","Run `git fetch origin v8` after creating or unshallowing a clone before invoking validators","Reuse the generator's _v8_available() probe to skip (not crash) when the ref is absent"],"tags":["git","ci","shallow-clone","validation","python"],"backgroundTag":null,"analyzedSha":"7fe58b0b0f3873be9a21c30106b8b8527c353aa6","analyzedAt":"2026-08-14T19:23:21.323Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}