Skip to content

fix(facts.git): GitLocalCommit fact failing on nonlocal ref#1881

Open
yagarea wants to merge 3 commits into
pyinfra-dev:3.xfrom
yagarea:3.x
Open

fix(facts.git): GitLocalCommit fact failing on nonlocal ref#1881
yagarea wants to merge 3 commits into
pyinfra-dev:3.xfrom
yagarea:3.x

Conversation

@yagarea

@yagarea yagarea commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Fixes: #1880


Its docstring explicitly promises: "returns None when the repository does not exist, the ref is unknown, or the command fails." And the process() method is written for that — it validates the output against a SHA regex and returns None otherwise.

But the shell command doesn't hold up its end. When the directory exists and the ref is unknown, git rev-parse exits with code 128. The 2>/dev/null hides the error text but does nothing about the exit code, so the whole fact command exits non-zero. pyinfra treats a failed fact command as fatal — Error: could not load fact — kicks the host out, and you get No hosts remaining!.


As per AI policy I disclose that test were created with assistance of LLM. I have read and tested them manually so its human verified.


  • Pull request is based on the default branch (3.x at this time)
  • Pull request includes tests for any new/updated operations/facts
  • Pull request includes documentation for any new/updated operations/facts
  • Tests pass (see scripts/dev-test.sh)
  • Type checking & code style passes (see scripts/dev-lint.sh)
  • Pull request title follows the
    conventional commits format

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GitLocalCommit fact fails (and kills the host) when the ref doesn't exist locally, breaking git.repo on version bumps

1 participant