Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

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

Open
#128 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
69/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
go
Domain
backend, security

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

bug good first issue

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.

Dominant language
Go
Stars
157
Forks
19
Avg merge
4h 28m
Merged PRs (30d)
88

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from solongate/agent-security

All issues in solongate/agent-security

Similar issues

More Go issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.