fix: stop the scratch-name match from pruning user directories
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 82/100
Research direction
Start at internal/indexdir/filter.go (besideStore, around lines 109-114), where the name-only strings.HasPrefix match lives, and check scratchdir.LockName for the content check to use instead. Then follow pruning in internal/indexer/discover/discoverexclusion.go:162-172 to see where the exclusion record is made. Reproduce with the mkdir/symlink steps in the issue; done means the user directory is indexed (or recorded with a reason) while real scratch dirs holding a .lock are still pruned, with a test under internal/indexdir.
Written by the indexing model from the issue text.
Description
What happens
The index skips any directory whose name starts with the store name followed by .scratch-. A user directory with such a name is skipped too. Discovery prunes it with no exclusion record, so its files are missing from the index and no reason is reported. This follows PR #384, which introduces the name match in internal/indexdir/filter.go.
Reproduced on commit 375d8be6 of branch fix/index-path-links, built from source:
$ codegraph index --force repo
files=1 nodes=2 edges=1 duration=82ms
Only repo/main.go is indexed. repo/store-real.scratch-notes/a.go is absent.
The cause is besideStore in internal/indexdir/filter.go:109-114. It matches a scratch directory by strings.HasPrefix on the name alone. DiscoverAll then prunes the matching directory before it makes any record (internal/indexer/discover/discoverexclusion.go:162-172).
What you expected instead
A directory that codegraph did not create is indexed as source, or it gets an exclusion record with a reason. Only a real scratch directory is pruned.
The match must check the content of the directory, such as its lock file .lock (scratchdir.LockName), and not the name alone. A scratch name ends in a random suffix, so the name cannot tell a scratch directory from a user directory.
Steps to reproduce
- Run
mkdir -p repo/.codegraph repo/store-real repo/store-real.scratch-notes. - Run
ln -s ../store-real repo/.codegraph/store. - Write
package atorepo/store-real.scratch-notes/a.go, andpackage maintorepo/main.go. - Run
codegraph index --force repo. Only one file is indexed.
Version
codegraph dev (commit unknown, built unknown) go1.26.11 darwin/arm64, built from 375d8be6.
Platform
macOS 27.2.1 arm64
How did you install it?
Built from source
Languages in the affected repository
Go. The bug depends on directory names, not on the language.
Before submitting
- I searched existing issues and this is not a duplicate
- I checked the capability matrix and this is not a documented limitation
- This is not a security vulnerability
- Dominant language
- Go
- Stars
- 0
- Forks
- 0
- Avg merge
- 5h 16m
- Merged PRs (30d)
- 107
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from seanb4t/codegraph-go
-
chore needs-triage
Difficulty 1/5 Under an hour Newbie friendliness 88/100
seanb4t/codegraph-go#380 ·
Maintainers usually reply within 1 day
-
chore needs-triage
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
seanb4t/codegraph-go#379 ·
Maintainers usually reply within 1 day
-
chore needs-triage
Difficulty 1/5 1-3 hours Newbie friendliness 84/100
seanb4t/codegraph-go#362 ·
Maintainers usually reply within 1 day
-
area:query bug priority:low spec-needed
Difficulty 2/5 1-3 hours Newbie friendliness 80/100
seanb4t/codegraph-go#355 ·
Maintainers usually reply within 1 day
-
area:ci chore priority:low
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
seanb4t/codegraph-go#329 ·
Maintainers usually reply within 1 day
All issues in seanb4t/codegraph-go
Similar issues
-
enhancement exporter/awskinesis needs triage
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
open-telemetry/opentelemetry-collector-contrib#53334 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
erigontech/erigon#26523 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 83/100
SocialGouv/iterion#3376 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 72/100
seaweedfs/seaweedfs#12740 · 2 comments ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day