Keep a green run green when git cannot list updated files - #8796
Open
trevor-vaughan wants to merge 1 commit into
Open
Keep a green run green when git cannot list updated files#8796trevor-vaughan wants to merge 1 commit into
trevor-vaughan wants to merge 1 commit into
Conversation
`list_updated_files()` called `repo.index.diff(None)` unguarded. On a
read-only workspace backed by git-lfs, the clean filter has nowhere to
write its temp files and the diff exits 128, so
`UpdatedSourcesReporter.produce_report()` raised `GitCommandError` and
failed a run in which every linter had passed.
Listing updated files is best effort, and the helper already returned
`[]` with a warning for the two other cases it cannot answer. It now
catches `GitCommandError` too. GitPython drains stderr before raising,
so the warning names the workspace and the failed command — otherwise
the user has nothing to diagnose from.
- fix(core): warn once per workspace instead of once per linted file
- In `file` lint mode the helper runs per file, and a workspace that
fails once keeps failing for the rest of the run; repeats drop to
debug level
- test(core): cover the four `list_updated_files` outcomes
- Nominal listing, the git-lfs failure, the warn-once behavior, and
the two pre-existing non-repository cases. Git config is neutralized
so the caller's global filters never reach the diff
- docs(reporters): explain an empty updated sources folder
- `UpdatedSourcesReporter.md` names the read-only + git-lfs cause and
points at mounting `.git` writable
Fixes: oxsecurity#8649
Assisted-by: Claude Opus 5
Signed-off-by: Trevor Vaughan <peiriannydd@gmail.com>
trevor-vaughan
force-pushed
the
fix/8649-git-lfs
branch
from
August 25, 2026 18:18
f97a80d to
8173284
Compare
trevor-vaughan
marked this pull request as ready for review
August 25, 2026 19:56
trevor-vaughan
requested review from
Kurt-von-Laven,
bdovaz,
echoix and
nvuillam
as code owners
August 25, 2026 19:56
nvuillam
approved these changes
Aug 26, 2026
nvuillam
left a comment
Member
There was a problem hiding this comment.
Good PR, thanks @trevor-vaughan 😊
nvuillam
enabled auto-merge (squash)
August 26, 2026 07:09
nvuillam
disabled auto-merge
August 26, 2026 07:09
Member
|
@trevor-vaughan plz can u merge conflicts so i can merge ? :) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A run where every linter passed could still exit with an error.
list_updated_files()ranrepo.index.diff(None)without a guard, and on a read-only workspace whose repository uses git-lfs the clean filter has nowhere to write its temporary files, so the diff exits 128 andUpdatedSourcesReporter.produce_report()propagated aGitCommandError.Listing updated files is best effort — the helper already returned
[]with a warning for the two other cases it cannot answer, so this addsGitCommandErrorto that set. TheUPDATED_SOURCES_REPORTER: falseworkaround is no longer needed.Changes
megalinter/utils.py: catchgit.GitCommandErrorinlist_updated_files()and return[]. GitPython drains stderr before raising, so the warning carries the workspace path and the failed command instead — that is all the user gets to diagnose fromLinter.update_files_lint_resultscalls the helper once per linted file infilemode, so subsequent failures for the same workspace log at debug levelmegalinter/tests/test_megalinter/utils_test.py: tests for the nominal listing, the git-lfs failure, the warn-once behavior, and both non-repository cases. Git config is neutralized (GIT_CONFIG_GLOBAL,GIT_CONFIG_SYSTEM, author/committer) so the caller's own filters never influence the diffdocs/reporters/UpdatedSourcesReporter.md: new "Empty updated sources folder" section explaining the cause and the.git-writable fixCHANGELOG.mdentry under CoreFixes #8649