config: Dir()'s HOME fallback is dead code and the regression test can't catch it
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 69/100
Research direction
Read core/config/paths.go around Dir() and trace the documented error behavior of os.UserConfigDir() against the fallback condition. Then inspect core/config/paths_test.go and determine how to force the lookup failure so the test executes the $HOME fallback. Done means the fallback is reachable for the actual failure case and the regression test fails if that behavior breaks.
Written by the indexing model from the issue text.
Description
Problem
Two related issues in packages/core/config:
paths.go:18—Dir()contains a fallback branch intended to handle the case where the primary config-directory lookup (e.g.os.UserConfigDir()) fails, falling back to constructing a path from$HOME; however, the condition guarding this fallback can never actually be reached given how the primary lookup behaves, making the fallback dead code.paths_test.go:21— the existing regression test for this fallback does not actually exercise the failure condition that would trigger it (e.g. it doesn't unset/mock the primary lookup's dependency), so it cannot detect that the fallback is unreachable.
Impact
If the primary config-directory lookup ever does fail in a real environment (e.g. an unusual OS/container configuration where os.UserConfigDir() errors), Dir() has no working fallback despite appearing to have one, and the test suite provides false confidence that this path is covered.
Repro
- Read
Dir()'s fallback condition and trace which inputs would need to hold for the primary lookup to fail in the way the fallback branch expects; observe the condition is unreachable underos.UserConfigDir()'s actual documented error behavior. - Run the existing test for this fallback with coverage instrumentation and observe the fallback branch is never actually executed.
Suggested fix
Rewrite Dir()'s fallback condition to correctly detect the primary lookup's actual failure mode (rather than a condition it can never produce), and update the regression test to force that failure path (e.g. by injecting a failing lookup function or manipulating the environment the test runs under) so it genuinely exercises the $HOME-based fallback and would catch a regression.
- Dominant language
- Go
- Stars
- 157
- Forks
- 19
- Avg merge
- 4h 28m
- Merged PRs (30d)
- 88
Getting set up
- No Dockerfile or Docker Compose file
- No 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 solongate/agent-security
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
solongate/agent-security#227 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 1/5 Under an hour Newbie friendliness 91/100
solongate/agent-security#226 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 1/5 Under an hour Newbie friendliness 88/100
solongate/agent-security#225 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
solongate/agent-security#224 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
solongate/agent-security#223 ·
Maintainers usually reply within 1 day
All issues in solongate/agent-security
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 78/100
slavakurilyak/awesome-ai-agents#880 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
apache/openserverless#282 · 2 comments ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
agent-butler-finding bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
jordansmall/spindrift#6161 ·
Maintainers usually reply within 1 day