DevWeave logoDevWeave
CommunitiesDiscoverHelp ForumFeaturesWhy DevWeaveAI & Verification
Log inGet started
Back to Issue Discovery
solongate/agent-security #128openGoCybersecurity

config: Dir()'s HOME fallback is dead code and the regression test can't catch it

Opened by @codeyevsky · Assignees: None

View on GitHub
buggood first issue

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)

690 GitHub Stars

Claim Status & GitHub Signal

Unassigned, with 1 comment. Unassigned does not guarantee unclaimed—read comments and linked PRs first.

AI Issue Assessment · Grounded Analyzer
2.8 / 10 · 3–4 · Beginner

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.

Skill Match Breakdown

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.

Log in to receive your free level-adapted Hint #1 grounded in this repository's files.

Skill-Gap Learning

Gap-Targeted
Learn Git

Branching, commits, rebasing, and collaborative Git workflows.

Addresses skill gap: Git & Collaboration

Learn Docker

Images, containers, volumes, and reproducible dev environments.

Addresses skill gap: Docker & Containers

Learn Object Oriented Programming in Python

Designing clean classes, encapsulation, and testable Python modules.

Addresses skill gap: Testing & pytest

Hands-On CodeCrafters Practice
Skill-Gap Challenge
Build your own Shell
Go

Parse commands, manage PATH lookups, pipes, and process execution.

Practice skill gap: Git & Collaboration

Build your own Git
Go

Implement .git storage, blob/tree objects, SHA hashing, and plumbing commands.

Practice skill gap: Git & Collaboration

Issue Description

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, the condition guarding this fallback can never actually be reached given how the primary lookup behaves, making the fallback dead code.
  2. 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

  1. 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 under os.UserConfigDir()'s actual documented error behavior.
  2. 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)

@harshdubey1234
View comment →

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.

Peer Help Forum · solongate/agent-security #128

Issue Troubleshooting Threads (0)

Ask Peers for Help

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.

Sign In

Contribution Workflow

Track your local progress before opening a pull request on GitHub.

Repository Context

Top Repository Paths

.all-contributorsrc
[dir] .github
.github/CODEOWNERS
.github/CODE_OF_CONDUCT.md
.github/CONTRIBUTING.md
[dir] .github/ISSUE_TEMPLATE
.github/ISSUE_TEMPLATE/bug_report.yaml
.github/ISSUE_TEMPLATE/config.yaml
.github/ISSUE_TEMPLATE/dlp_pattern.yaml
.github/ISSUE_TEMPLATE/feature_request.yaml
.github/SECURITY.md
.github/dependabot.yaml
[dir] .github/workflows
.github/workflows/all-contributors.yaml
.github/workflows/backfill-attestation.yaml
.github/workflows/ci.yaml
.github/workflows/codeql.yaml
.github/workflows/release.yaml
.github/workflows/scorecard.yaml
.github/workflows/trivy.yaml
.gitignore
.gitleaks.toml
.trivyignore
CHANGELOG.md

Advisory PR Assistant

Helps structure your PR description or unpack reviewer feedback. Does not perform GitHub actions.