config: Dir()'s HOME fallback is dead code and the regression test can't catch it
Opened by @codeyevsky · Assignees: None
Solve & Merge Reward: Up to +244 XP & +60 Coins
+30 XP on PR open · +180 XP & +60 coins on merge · +34 star XP (690 stars)
Claim Status & GitHub Signal
Unassigned, with 1 comment. Unassigned does not guarantee unclaimed—read comments and linked PRs first.
Estimated from issue labels (bug, good first issue), Go context, and discussion depth. There are 1 GitHub comments to review for maintainer clarifications. Note: this is an estimate, not a guarantee.
What It's About
config: Dir()'s HOME fallback is dead code and the regression test can't catch it. Problem Two related issues in packages/core/config: 1. 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
Why It Matters
Resolving #128 improves reliability and developer experience in solongate/agent-security.
Expected Outcome
A focused pull request addressing #128 with relevant checks or tests verified locally.
Log in to compare this issue's requirements against your profile skills. Required concepts: Testing & pytest, Docker & Containers, Git & Collaboration, AppSec & Validation.
Progressive AI Hints
Hint #1 is always free and calibrated to your experience level. Extra hints unlock with coins without spoiling the full solution.
Skill-Gap Learning
Branching, commits, rebasing, and collaborative Git workflows.
Addresses skill gap: Git & Collaboration
Images, containers, volumes, and reproducible dev environments.
Addresses skill gap: Docker & Containers
Designing clean classes, encapsulation, and testable Python modules.
Addresses skill gap: Testing & pytest
Issue 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.
Linked Pull Requests (0)
No linked or cross-referenced pull requests detected via GitHub timeline. Check comments below for informal claims before starting.
GitHub Comments (1)
I've opened a fix for this in https://github.com/solongate/agent-security/pull/470. When HOME is unset, SGDir now falls back to the account record from os/user, which doesn't depend on any environment variable, so the folder stays at ~/.solongate instead of a relative .solongate in the working directory. I also tightened the config test to require an absolute path. It now fails on main with Dir() = ".solongate" and passes with the fix.
Issue Troubleshooting Threads (0)
No troubleshooting threads opened for this issue yet. If you hit a test, build, or navigation blocker, post what you've tried so fellow contributors can help.
PR Verification & Rewards
Sign in and link GitHub to verify your PR against this issue and earn XP + coins.
Contribution Workflow
Track your local progress before opening a pull request on GitHub.
Repository Context
Top Repository Paths
Advisory PR Assistant
Helps structure your PR description or unpack reviewer feedback. Does not perform GitHub actions.