Skip to content

Fix uncaught TimeoutExpired crash in merge_base_with_main() for shim linters - #189419

Closed
janeyx99 with Copilot wants to merge 5 commits into
mainfrom
copilot/fix-lintrunner-noclang-all-failure
Closed

janeyx99 with Copilot wants to merge 5 commits into
mainfrom
copilot/fix-lintrunner-noclang-all-failure

Conversation

Copilot AI commented Jul 9, 2026 •

Copy link
Copy Markdown
Contributor

Don't crash with error when the first git catfile command times out due to partial clone in CI. Instead, just fall back to the slower fetch.

@pytorch-bot

pytorch-bot Bot commented Jul 9, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/189419

Note: Links to docs will display an error until the docs builds have been completed.

✅ No Failures

As of commit 7b4ac3a with merge base 1ba55ce (image):
💚 Looks good so far! There are no failures yet. 💚

This comment was automatically generated by Dr. CI and updates every 15 minutes.

…at-file timeout

The lintrunner-noclang-all CI job was failing with:

  RuntimeError: Failed to get git diff information for .../shim.h.
  Error: Command ['git', 'cat-file', '-e', '<sha>^{commit}'] timed out after 5 seconds

In merge_base_with_main() (_stable_shim_utils.py), a git cat-file -e probe
checks whether the latest origin/main commit already exists locally. On large
or partial-clone repos this probe occasionally takes >5 s and raises
subprocess.TimeoutExpired, which was uncaught and propagated as an unhandled
exception, crashing the linter.

Fix: catch TimeoutExpired from the cat-file call and treat it identically to
a non-zero exit code (commit not found locally). The subsequent git fetch
--no-write-fetch-head will retrieve the missing commit and the merge-base
computation will succeed.

Test Plan:
```
python -c "import ast; ast.parse(open('tools/linter/adapters/_stable_shim_utils.py').read()); print('OK')"
```

Authored with Claude.
@pytorch-bot pytorch-bot Bot added the topic: not user facing topic category label Jul 9, 2026
Copilot AI changed the title [WIP] Fix failing GitHub Actions job lintrunner-noclang-all Fix uncaught TimeoutExpired crash in merge_base_with_main() for shim linters Jul 9, 2026
Copilot AI requested a review from janeyx99 July 9, 2026 16:28
@janeyx99
janeyx99 marked this pull request as ready for review July 9, 2026 18:05

@albanD albanD left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ookk

@Skylion007

Copy link
Copy Markdown
Collaborator

@pytorchbot fix-lint

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Successfully applied lint patches in https://github.com/pytorch/pytorch/actions/runs/29043599986. Please pull locally before pushing more changes.

@janeyx99

janeyx99 commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

@pytorchbot merge

1 similar comment
@janeyx99

janeyx99 commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

@pytorchbot merge

@janeyx99

janeyx99 commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

@pytorchbot merge -f "pull and lint pass, though I am confused y my other merge commands didn;t work"

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Merge started

Your change will be merged immediately since you used the force (-f) flag, bypassing any CI checks (ETA: 1-5 minutes). Please use -f as last resort and instead consider -i/--ignore-current to continue the merge ignoring current failures. This will allow currently pending tests to finish and report signal before the merge.

Learn more about merging in the wiki.

Questions? Feedback? Please reach out to the PyTorch DevX Team

Advanced Debugging
Check the merge workflow status
here

ValerianRey pushed a commit to ValerianRey/pytorch that referenced this pull request Jul 10, 2026
…linters (pytorch#189419)

Don't crash with error when the first `git catfile` command times out due to partial clone in CI. Instead, just fall back to the slower fetch.
Pull Request resolved: pytorch#189419
Approved by: https://github.com/albanD

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: Jane (Yuan) Xu <[email protected]>
Co-authored-by: PyTorch MergeBot <[email protected]>
frgossen added a commit that referenced this pull request Jul 14, 2026
…hing

Follows the pattern from #189419: keep the short 5s timeout (plenty when git
objects are local) and, on subprocess.TimeoutExpired, take an explicit graceful
fallback rather than raising the ceiling. A timeout signals the objects are not
present in the partial clone, not that we should wait longer, and bumping the
default only blocks every cold call while hiding that condition.

The two blob-reading call sites are handled per their linter's semantics:

- stable_shim_version_linter.get_added_lines (the two git diff calls): on
  timeout, fall back to an empty added-lines set. Enforcement then only applies
  to lines confirmed new; the AOTI shim's existing declarations are already
  exempt when not newly added, so this cannot false-positive.

- generated_shims_version_linter (the git show base read): on timeout, skip the
  check (return no messages). Crucially this must NOT reuse the "file absent"
  path, which treats every current op as newly added: with the base empty, all
  already-versioned ops (currently 2.10-2.13 against a 2.14 tree) would be
  flagged wrong-version, turning a flaky infra timeout into ~24 false errors.

The git merge-base call is left at 5s untouched: it only walks the commit graph,
which a blobless partial clone has in full, so it never touches the network.

Test Plan: lintrunner on the three adapters passes (STABLE_SHIM_VERSION and
GENERATED_SHIMS_VERSION clean). The partial-clone network timeout is CI-only and
not deterministically reproducible locally.

ghstack-source-id: edc3e6d
Pull-Request: #189947

Authored with Claude.
frgossen added a commit that referenced this pull request Jul 14, 2026
…hing

Follows the pattern from #189419: keep the short 5s timeout (plenty when git
objects are local) and, on subprocess.TimeoutExpired, take an explicit graceful
fallback rather than raising the ceiling. A timeout signals the objects are not
present in the partial clone, not that we should wait longer, and bumping the
default only blocks every cold call while hiding that condition.

The two blob-reading call sites are handled per their linter's semantics:

- stable_shim_version_linter.get_added_lines (the two git diff calls): on
  timeout, fall back to an empty added-lines set. Enforcement then only applies
  to lines confirmed new; the AOTI shim's existing declarations are already
  exempt when not newly added, so this cannot false-positive.

- generated_shims_version_linter (the git show base read): on timeout, skip the
  check (return no messages). Crucially this must NOT reuse the "file absent"
  path, which treats every current op as newly added: with the base empty, all
  already-versioned ops (currently 2.10-2.13 against a 2.14 tree) would be
  flagged wrong-version, turning a flaky infra timeout into ~24 false errors.

The git merge-base call is left at 5s untouched: it only walks the commit graph,
which a blobless partial clone has in full, so it never touches the network.

Test Plan: lintrunner on the three adapters passes (STABLE_SHIM_VERSION and
GENERATED_SHIMS_VERSION clean). The partial-clone network timeout is CI-only and
not deterministically reproducible locally.

ghstack-source-id: edc3e6d
Pull-Request: #189947

Authored with Claude.
pytorchmergebot pushed a commit that referenced this pull request Jul 15, 2026
#189444 bumped the git cat-file timeout in merge_base_with_main() from 5s to
60s. That defeats the design introduced in #189419, which deliberately keeps a
short 5s timeout and catches subprocess.TimeoutExpired to fall back to the
slower git fetch: a timeout is the signal that the object is not present in the
partial clone, not something to wait out. Bumping to 60s just makes every cold
call block and masks that condition. Restore the 5s timeout so the graceful
fallback triggers promptly as intended.

Test Plan: lintrunner on _stable_shim_utils.py passes. The STABLE_SHIM_VERSION /
GENERATED_SHIMS_VERSION linters continue to resolve the merge base via the
try/except fallback on partial-clone CI checkouts.

Authored with Claude.
Pull Request resolved: #189946
Approved by: https://github.com/janeyx99
vishalgoyal316 pushed a commit to vishalgoyal316/pytorch that referenced this pull request Jul 16, 2026
…linters (pytorch#189419)

Don't crash with error when the first `git catfile` command times out due to partial clone in CI. Instead, just fall back to the slower fetch.
Pull Request resolved: pytorch#189419
Approved by: https://github.com/albanD

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: Jane (Yuan) Xu <[email protected]>
Co-authored-by: PyTorch MergeBot <[email protected]>
DamJanusz pushed a commit to DamJanusz/pytorch that referenced this pull request Jul 21, 2026
…linters (pytorch#189419)

Don't crash with error when the first `git catfile` command times out due to partial clone in CI. Instead, just fall back to the slower fetch.
Pull Request resolved: pytorch#189419
Approved by: https://github.com/albanD

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: Jane (Yuan) Xu <[email protected]>
Co-authored-by: PyTorch MergeBot <[email protected]>
DamJanusz pushed a commit to DamJanusz/pytorch that referenced this pull request Jul 21, 2026
…torch#189946)

pytorch#189444 bumped the git cat-file timeout in merge_base_with_main() from 5s to
60s. That defeats the design introduced in pytorch#189419, which deliberately keeps a
short 5s timeout and catches subprocess.TimeoutExpired to fall back to the
slower git fetch: a timeout is the signal that the object is not present in the
partial clone, not something to wait out. Bumping to 60s just makes every cold
call block and masks that condition. Restore the 5s timeout so the graceful
fallback triggers promptly as intended.

Test Plan: lintrunner on _stable_shim_utils.py passes. The STABLE_SHIM_VERSION /
GENERATED_SHIMS_VERSION linters continue to resolve the merge base via the
try/except fallback on partial-clone CI checkouts.

Authored with Claude.
Pull Request resolved: pytorch#189946
Approved by: https://github.com/janeyx99
pytorchmergebot pushed a commit that referenced this pull request Jul 27, 2026
…y fetch (#191228)

The STABLE_SHIM_VERSION linter intermittently fails in CI with
`subprocess.TimeoutExpired` on `git diff <merge_base>..HEAD -- shim.h`,
reported as an internal linter bug.

Root cause: CI checks out a blobless partial clone (`--filter=blob:none`, added
in #172544; see .github/actions/checkout-pytorch/action.yml). The 5s diff
timeout predates that (added with the linter in #166995) and was correct then --
the diff was purely local. `merge_base_with_main()` fetches the merge-base
*commit* ahead of time, but the blobless filter deliberately omits file contents
even for explicitly fetched commits, so the merge-base blob of the linted file
is never local. When `git diff` needs it, git triggers an on-demand lazy fetch
in the middle of the command -- an uncontrolled network round-trip that races
the 5s timeout under the network contention of lintrunner running adapters
concurrently.

This is the same partial-clone symptom #189419 already fixed for the sibling
`git cat-file` probe in `merge_base_with_main()`, which was simply never applied
to the `git diff`/`git show` paths. #189419 established the design: keep a short
timeout as a fast "is it local?" probe and, on absence, fall back to an
explicit, controlled `git fetch`. #189444 tried to instead bump the probe
timeout to wait the lazy fetch out; #189946 reverted that, on the grounds that a
timeout is the signal that the object is not present, not something to wait out.
So bumping the diff timeout (or wrapping the diff in the retrying fetch helper to
wait it out) would repeat the already-reverted mistake.

Fix: apply #189419's design to the missing blob. `ensure_diff_blob_local()`
resolves the blob OID offline (trees are present under blob:none) and, only if
it is missing locally, fetches that single object through the existing retrying
network helper; the diff/show then runs entirely from local objects with a
short, honest timeout. `GIT_NO_LAZY_FETCH=1` guards the resolution and presence
checks so they cannot themselves trigger a fetch -- a deterministic improvement
over the cat-file probe's timeout race. In a full clone the blob is already
present and this is a no-op with no network access. The generated-shims linter's
prior 60s `git show` workaround is replaced by the same prefetch + 5s timeout.

Test Plan:
Verified locally in a full clone that the helper is a no-op and the git command
stays local and fast:

```
python tools/linter/adapters/stable_shim_version_linter.py \
    torch/csrc/inductor/aoti_torch/c/shim.h
```

End-to-end validation on a blobless partial clone still needs to run (the
sandbox has no network); it must confirm the single-blob
`git fetch --no-write-fetch-head origin <oid>` succeeds against GitHub's
promisor endpoint. If the explicit single-object fetch is rejected there, the
fallback is to trigger git's native lazy fetch through the same retry wrapper
(e.g. `git cat-file -p <oid>`).

Authored-with: Claude (AI assistant)
Pull Request resolved: #191228
Approved by: https://github.com/albanD, https://github.com/Skylion007, https://github.com/janeyx99
youlituao pushed a commit to youlituao/pytorch that referenced this pull request Jul 28, 2026
…linters (pytorch#189419)

Don't crash with error when the first `git catfile` command times out due to partial clone in CI. Instead, just fall back to the slower fetch.
Pull Request resolved: pytorch#189419
Approved by: https://github.com/albanD

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: Jane (Yuan) Xu <[email protected]>
Co-authored-by: PyTorch MergeBot <[email protected]>
youlituao pushed a commit to youlituao/pytorch that referenced this pull request Jul 28, 2026
…torch#189946)

pytorch#189444 bumped the git cat-file timeout in merge_base_with_main() from 5s to
60s. That defeats the design introduced in pytorch#189419, which deliberately keeps a
short 5s timeout and catches subprocess.TimeoutExpired to fall back to the
slower git fetch: a timeout is the signal that the object is not present in the
partial clone, not something to wait out. Bumping to 60s just makes every cold
call block and masks that condition. Restore the 5s timeout so the graceful
fallback triggers promptly as intended.

Test Plan: lintrunner on _stable_shim_utils.py passes. The STABLE_SHIM_VERSION /
GENERATED_SHIMS_VERSION linters continue to resolve the merge base via the
try/except fallback on partial-clone CI checkouts.

Authored with Claude.
Pull Request resolved: pytorch#189946
Approved by: https://github.com/janeyx99
aws-kingrj pushed a commit to amazon-contributing/upstream-to-pytorch that referenced this pull request Jul 29, 2026
…linters (pytorch#189419)

Don't crash with error when the first `git catfile` command times out due to partial clone in CI. Instead, just fall back to the slower fetch.
Pull Request resolved: pytorch#189419
Approved by: https://github.com/albanD

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: Jane (Yuan) Xu <[email protected]>
Co-authored-by: PyTorch MergeBot <[email protected]>
aws-kingrj pushed a commit to amazon-contributing/upstream-to-pytorch that referenced this pull request Jul 29, 2026
…torch#189946)

pytorch#189444 bumped the git cat-file timeout in merge_base_with_main() from 5s to
60s. That defeats the design introduced in pytorch#189419, which deliberately keeps a
short 5s timeout and catches subprocess.TimeoutExpired to fall back to the
slower git fetch: a timeout is the signal that the object is not present in the
partial clone, not something to wait out. Bumping to 60s just makes every cold
call block and masks that condition. Restore the 5s timeout so the graceful
fallback triggers promptly as intended.

Test Plan: lintrunner on _stable_shim_utils.py passes. The STABLE_SHIM_VERSION /
GENERATED_SHIMS_VERSION linters continue to resolve the merge base via the
try/except fallback on partial-clone CI checkouts.

Authored with Claude.
Pull Request resolved: pytorch#189946
Approved by: https://github.com/janeyx99
aws-kingrj pushed a commit to amazon-contributing/upstream-to-pytorch that referenced this pull request Jul 29, 2026
…y fetch (pytorch#191228)

The STABLE_SHIM_VERSION linter intermittently fails in CI with
`subprocess.TimeoutExpired` on `git diff <merge_base>..HEAD -- shim.h`,
reported as an internal linter bug.

Root cause: CI checks out a blobless partial clone (`--filter=blob:none`, added
in pytorch#172544; see .github/actions/checkout-pytorch/action.yml). The 5s diff
timeout predates that (added with the linter in pytorch#166995) and was correct then --
the diff was purely local. `merge_base_with_main()` fetches the merge-base
*commit* ahead of time, but the blobless filter deliberately omits file contents
even for explicitly fetched commits, so the merge-base blob of the linted file
is never local. When `git diff` needs it, git triggers an on-demand lazy fetch
in the middle of the command -- an uncontrolled network round-trip that races
the 5s timeout under the network contention of lintrunner running adapters
concurrently.

This is the same partial-clone symptom pytorch#189419 already fixed for the sibling
`git cat-file` probe in `merge_base_with_main()`, which was simply never applied
to the `git diff`/`git show` paths. pytorch#189419 established the design: keep a short
timeout as a fast "is it local?" probe and, on absence, fall back to an
explicit, controlled `git fetch`. pytorch#189444 tried to instead bump the probe
timeout to wait the lazy fetch out; pytorch#189946 reverted that, on the grounds that a
timeout is the signal that the object is not present, not something to wait out.
So bumping the diff timeout (or wrapping the diff in the retrying fetch helper to
wait it out) would repeat the already-reverted mistake.

Fix: apply pytorch#189419's design to the missing blob. `ensure_diff_blob_local()`
resolves the blob OID offline (trees are present under blob:none) and, only if
it is missing locally, fetches that single object through the existing retrying
network helper; the diff/show then runs entirely from local objects with a
short, honest timeout. `GIT_NO_LAZY_FETCH=1` guards the resolution and presence
checks so they cannot themselves trigger a fetch -- a deterministic improvement
over the cat-file probe's timeout race. In a full clone the blob is already
present and this is a no-op with no network access. The generated-shims linter's
prior 60s `git show` workaround is replaced by the same prefetch + 5s timeout.

Test Plan:
Verified locally in a full clone that the helper is a no-op and the git command
stays local and fast:

```
python tools/linter/adapters/stable_shim_version_linter.py \
    torch/csrc/inductor/aoti_torch/c/shim.h
```

End-to-end validation on a blobless partial clone still needs to run (the
sandbox has no network); it must confirm the single-blob
`git fetch --no-write-fetch-head origin <oid>` succeeds against GitHub's
promisor endpoint. If the explicit single-object fetch is rejected there, the
fallback is to trigger git's native lazy fetch through the same retry wrapper
(e.g. `git cat-file -p <oid>`).

Authored-with: Claude (AI assistant)
Pull Request resolved: pytorch#191228
Approved by: https://github.com/albanD, https://github.com/Skylion007, https://github.com/janeyx99
MelindaTan pushed a commit to MelindaTan/pytorch that referenced this pull request Jul 31, 2026
…y fetch (pytorch#191228)

The STABLE_SHIM_VERSION linter intermittently fails in CI with
`subprocess.TimeoutExpired` on `git diff <merge_base>..HEAD -- shim.h`,
reported as an internal linter bug.

Root cause: CI checks out a blobless partial clone (`--filter=blob:none`, added
in pytorch#172544; see .github/actions/checkout-pytorch/action.yml). The 5s diff
timeout predates that (added with the linter in pytorch#166995) and was correct then --
the diff was purely local. `merge_base_with_main()` fetches the merge-base
*commit* ahead of time, but the blobless filter deliberately omits file contents
even for explicitly fetched commits, so the merge-base blob of the linted file
is never local. When `git diff` needs it, git triggers an on-demand lazy fetch
in the middle of the command -- an uncontrolled network round-trip that races
the 5s timeout under the network contention of lintrunner running adapters
concurrently.

This is the same partial-clone symptom pytorch#189419 already fixed for the sibling
`git cat-file` probe in `merge_base_with_main()`, which was simply never applied
to the `git diff`/`git show` paths. pytorch#189419 established the design: keep a short
timeout as a fast "is it local?" probe and, on absence, fall back to an
explicit, controlled `git fetch`. pytorch#189444 tried to instead bump the probe
timeout to wait the lazy fetch out; pytorch#189946 reverted that, on the grounds that a
timeout is the signal that the object is not present, not something to wait out.
So bumping the diff timeout (or wrapping the diff in the retrying fetch helper to
wait it out) would repeat the already-reverted mistake.

Fix: apply pytorch#189419's design to the missing blob. `ensure_diff_blob_local()`
resolves the blob OID offline (trees are present under blob:none) and, only if
it is missing locally, fetches that single object through the existing retrying
network helper; the diff/show then runs entirely from local objects with a
short, honest timeout. `GIT_NO_LAZY_FETCH=1` guards the resolution and presence
checks so they cannot themselves trigger a fetch -- a deterministic improvement
over the cat-file probe's timeout race. In a full clone the blob is already
present and this is a no-op with no network access. The generated-shims linter's
prior 60s `git show` workaround is replaced by the same prefetch + 5s timeout.

Test Plan:
Verified locally in a full clone that the helper is a no-op and the git command
stays local and fast:

```
python tools/linter/adapters/stable_shim_version_linter.py \
    torch/csrc/inductor/aoti_torch/c/shim.h
```

End-to-end validation on a blobless partial clone still needs to run (the
sandbox has no network); it must confirm the single-blob
`git fetch --no-write-fetch-head origin <oid>` succeeds against GitHub's
promisor endpoint. If the explicit single-object fetch is rejected there, the
fallback is to trigger git's native lazy fetch through the same retry wrapper
(e.g. `git cat-file -p <oid>`).

Authored-with: Claude (AI assistant)
Pull Request resolved: pytorch#191228
Approved by: https://github.com/albanD, https://github.com/Skylion007, https://github.com/janeyx99
@github-actions
github-actions Bot deleted the copilot/fix-lintrunner-noclang-all-failure branch August 9, 2026 02:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants