Default configuration path falls back to the current directory when the home directory cannot be determined
维护者通常 1 天内回复
评估
调研方向
从 pkg/config/localconfig.go 中的 DefaultConfigDir 和 DefaultLocalConfigPath 入手,然后追踪 context list 等命令如何加载默认本地配置。检查如何处理查找主目录时发生的错误,以及所选行为如何同时应用于读取和写入。完成标准是:查找主目录失败时不再生成相对于当前目录的配置路径,并且 CLI 会报告明确的错误或使用经过审慎选择的回退方案。
由索引模型根据 Issue 内容生成。
描述
Describe the bug
When MICROCKS_CONFIG_DIR is unset and the CLI cannot determine the user's home directory, DefaultConfigDir in pkg/config/localconfig.go discards the error returned by getHomeDir() and returns an empty string with no error.
DefaultLocalConfigPath then constructs the configuration path using this empty directory. Instead of returning an error or selecting a documented fallback, the resulting path can be the relative path config.
This creates an unexpected dependency on the process's current working directory. Commands that load or save local configuration may consequently resolve the configuration file relative to whichever directory the CLI was launched from, rather than using a stable, user-specific configuration directory.
Depending on the command and its execution path, this could cause the CLI to read an unintended file, create configuration in an unexpected location, or fail in a way that obscures the underlying problem. If the relative file contains authentication data, using an unintended location could also create a credential-handling risk.
Expected behavior
The CLI should not silently accept an empty configuration directory after home-directory resolution fails.
It should either:
Return a clear, actionable error indicating that the home directory could not be determined; or
Use a documented and deliberate fallback location that does not unexpectedly resolve to a file in the current working directory.
The selected behavior should be consistent for commands that read and write the default configuration.
Actual behavior
The error from getHomeDir() is discarded, and DefaultConfigDir returns an empty path with a nil error. DefaultLocalConfigPath can consequently resolve to the relative path config, allowing subsequent file operations to depend on the current working directory.
How to Reproduce?
-
Build the CLI or a small diagnostic program against the affected source.
-
Create and switch to a temporary working directory that does not contain an existing configuration file.
-
Unset MICROCKS_CONFIG_DIR and the relevant home-directory environment variables. On Windows, unset USERPROFILE; on Unix-like systems, unset HOME.
-
Call config.DefaultLocalConfigPath() or run a CLI command that loads the default local configuration, such as context list.
-
Inspect the resolved path and the command's behavior.
For a direct path-resolution check, call DefaultLocalConfigPath() and print both its returned path and error. Under the affected conditions, the expected reproduction is a relative path such as config with no reported error.
To verify actual file access separately, place a harmless, deliberately malformed test configuration file named config in the temporary working directory and run a command that loads the local configuration. A parsing error can help demonstrate that the relative file is being read. Do not use real configuration files or credentials for this test.
Microcks version or git rev
main
Install method (docker-compose, helm chart, operator, docker-desktop extension,...)
CLI
Additional information
No response
- 主要语言
- Go
- 星标
- 57
- 派生
- 73
- 平均合并
- 1 天 9 小时
- 30 天内合并 PR
- 28
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
microcks/microcks-cli 的其他 Issue
-
难度 1/5 1 小时以内 新手友好度 88/100
microcks/microcks-cli#573 · 1 条评论 ·
维护者通常 1 天内回复
-
bug: YAML parse error in config is silently swallowed, login overwrites all other contexts可能已有人在做 @Sarthak-Shreshtha01 于 5 天前认领。 未关闭component/cli kind/bug
难度 2/5 1-3 小时 新手友好度 76/100
microcks/microcks-cli#572 · 5 条评论 ·
维护者通常 1 天内回复
-
import-dir uploads secondary artifacts before their primary API definition可能已有人在做 @doraem-on 于 12 天前认领。 未关闭component/cli kind/bug
难度 2/5 1-3 小时 新手友好度 88/100
microcks/microcks-cli#561 · 3 条评论 ·
维护者通常 1 天内回复
-
TEST: `ConnectAndGetToken` Returns Error on Non-200 Response可能已有人在做 @aniket866 于 15 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 84/100
microcks/microcks-cli#554 ·
维护者通常 1 天内回复
-
Empty `AuthToken` Causes Cryptic JWT Parse Error可能已有人在做 @aniket866 于 15 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 86/100
microcks/microcks-cli#551 ·
维护者通常 1 天内回复
查看 microcks/microcks-cli 的全部 Issue
相似的 Issue
-
triage/pending-triage
难度 2/5 1-3 小时 新手友好度 74/100
external-secrets/external-secrets#7117 ·
维护者通常 2 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 72/100
ENTERPILOT/GoModel#1183 · 1 条评论 ·
维护者通常 1 天内回复
-
enhancement good first issue
难度 2/5 1-3 小时 新手友好度 68/100
Edwin-metcalf/MetCode#16 ·
-
Action Required: Fix Renovate Configuration可能已有人在做 @thompson-tomo 今天认领。 未关闭
难度 1/5 1 小时以内 新手友好度 78/100
open-telemetry/opentelemetry-collector#16170 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 70/100
维护者通常 1 天内回复