Repository navigation
fix(desktop): false positive LFS detection from .lfsconfig - #1246
Conversation
Remove .lfsconfig from the LFS detection check. The file only configures LFS behaviour (e.g. locksverify) and does not indicate that files are tracked with LFS. This caused workspace creation to fail for repos with a .lfsconfig but no actual LFS-tracked files.
📝 WalkthroughWalkthroughThe PR fixes a bug where Git LFS detection incorrectly identifies repositories as using LFS based solely on the presence of a Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
@Kitenite found this bug today when I went to try and create a new workspace in my superset repo, and it would not create because of the above error. |
Kitenite
left a comment
There was a problem hiding this comment.
Review: LGTM
Summary: Clean, correct, and minimal fix for a real false-positive bug.
Analysis
The root cause is clear: .lfsconfig is an INI-format config file (server URLs, lock settings) where [lfs] is just a section header present in every .lfsconfig file. Checking it alongside .gitattributes and .git/info/attributes — which use an entirely different format — was a category error. Any repo with a .lfsconfig would hit the content.includes("[lfs]") branch and falsely report LFS usage.
The remaining four detection methods are robust and cover all legitimate LFS scenarios:
.git/lfs/directory — LFS objects are present.gitattributeswithfilter=lfs— files configured for tracking.git/info/attributeswithfilter=lfs— same, local override locationgit check-attr filteron sample files — runtime attribute check
Test update
The test change is appropriate — it now asserts the correct behavior (.lfsconfig alone ≠ LFS detection) instead of the incorrect behavior it was previously verifying.
Minor observation (not blocking)
The condition on line 258 still checks content.includes("[lfs]") for .gitattributes and .git/info/attributes. Since those files use gitattributes format (not INI), [lfs] would never appear in a well-formed attributes file, so this branch is dead code for the remaining files. Could be cleaned up separately but is harmless.
Kitenite
left a comment
There was a problem hiding this comment.
Review: LGTM
Summary: Clean, correct, and minimal fix for a real false-positive bug.
Analysis
The root cause is clear: .lfsconfig is an INI-format config file (server URLs, lock settings) where [lfs] is just a section header present in every .lfsconfig file. Checking it alongside .gitattributes and .git/info/attributes — which use an entirely different format — was a category error. Any repo with a .lfsconfig would hit the content.includes("[lfs]") branch and falsely report LFS usage.
The remaining four detection methods are robust and cover all legitimate LFS scenarios:
.git/lfs/directory — LFS objects are present.gitattributeswithfilter=lfs— files configured for tracking.git/info/attributeswithfilter=lfs— same, local override locationgit check-attr filteron sample files — runtime attribute check
Test update
The test change is appropriate — it now asserts the correct behavior (.lfsconfig alone does not equal LFS detection) instead of the incorrect behavior it was previously verifying.
Minor observation (not blocking)
The condition on line 258 still checks content.includes("[lfs]") for .gitattributes and .git/info/attributes. Since those files use gitattributes format (not INI), [lfs] would never appear in a well-formed attributes file, so this branch is dead code for the remaining files. Could be cleaned up separately but is harmless.
|
My bad claude code decided to make those comments. Don't worry, i actually review PRs haha |
|
Thanks @de1mat ! |
Description
The
repoUsesLfs()function checks.lfsconfigfor the string[lfs]and treats it as evidence that the repo tracks files with LFS. However,.lfsconfigis a configuration file for LFS behaviour (server URLs, lock settings) - the[lfs]string is just an INI section header present in every.lfsconfigfile.The superset.sh repo itself has a
.lfsconfigwith onlylocksverify = false, which triggers a false positive. This blocks workspace creation with a "please install git-lfs" error even though no files are tracked with LFS.Here is a screenshot of trying to create a new workspace using the superset repo:
This PR removes
.lfsconfigfrom the attribute file check. The remaining detection methods are sufficient:.git/lfs/directory (LFS objects present).gitattributeswithfilter=lfs(files configured for LFS tracking).git/info/attributeswithfilter=lfsgit check-attr filteron sample filesRelated Issues
Fixes #1244
Type of Change
Testing
.lfsconfigalone does not trigger LFS detection