bug: YAML parse error in config is silently swallowed, login overwrites all other contexts
维护者通常 1 天内回复
评估
调研方向
从 localconfig.go 第 103 行附近开始,比较 ReadLocalConfig 和 ReadLocalWatchConfig 如何处理 configUtil.UnmarshalLocalFile 返回的错误。然后阅读 config_test.go,为两个读取器添加针对格式错误 YAML 的测试。完成标准是返回解析错误,而不是将其视为空配置;文件缺失时仍返回 nil, nil。
由索引模型根据 Issue 内容生成。
描述
A tab instead of spaces — or any YAML syntax error — in the config file causes ReadLocalConfig to return an empty config with no error, making every command behave as if the user has never logged in.
The dangerous part: login sees the empty config, treats it as a fresh install, and writes a brand-new file over it. Every other context, server, user and refresh token in the file is gone with no warning.
Root cause
localconfig.go line 103:
err = configUtil.UnmarshalLocalFile(path, &config)
if os.IsNotExist(err) {
return nil, nil
}
err = ValidateLocalConfig(config) // parse error is silently overwritten here
Only os.IsNotExist is handled. A YAML parse error falls through and gets immediately overwritten by ValidateLocalConfig. Same bug in ReadLocalWatchConfig.
To reproduce
- Put a tab on any indented line in
~/.config/microcks/config - Run
microcks context→ reports "no contexts defined" instead of a parse error - Run
microcks login <any-server>→ the file is truncated and rewritten. All previous contexts are gone.
Fix
if err != nil {
return nil, fmt.Errorf("reading config %s: %w", path, err)
}
Same in ReadLocalWatchConfig. After this, nil, nil keeps its only meaning — file doesn't exist — and fresh-install logic stays untouched.
There is no test for malformed input in config_test.go, which is how this went unnoticed.
- 主要语言
- Go
- 星标
- 58
- 派生
- 72
- 平均合并
- 1 天 11 小时
- 30 天内合并 PR
- 27
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
microcks/microcks-cli 的其他 Issue
-
Wrong link to test results可能已有人在做 @SajanBisht 今天认领。 未关闭component/cli keep-open kind/bug
难度 2/5 1-3 小时 新手友好度 62/100
microcks/microcks-cli#589 · 3 条评论 ·
维护者通常 1 天内回复
-
Default configuration path falls back to the current directory when the home directory cannot be determined可能已有人在做 @Sarthak-Shreshtha01 于 4 天前认领。 未关闭component/cli kind/bug
难度 2/5 1-3 小时 新手友好度 76/100
microcks/microcks-cli#583 · 5 条评论 ·
维护者通常 1 天内回复
-
microcks test exits with code 1 (contract failure) instead of code 11 (connection) when polling loop times out可能已有人在做 @ish-g09 于 3 天前认领。 未关闭component/cli kind/bug
难度 1/5 1 小时以内 新手友好度 88/100
microcks/microcks-cli#573 · 5 条评论 ·
维护者通常 1 天内回复
-
import-dir uploads secondary artifacts before their primary API definition可能已有人在做 @doraem-on 于 16 天前认领。 未关闭component/cli kind/bug
难度 2/5 1-3 小时 新手友好度 88/100
microcks/microcks-cli#561 · 4 条评论 ·
维护者通常 1 天内回复
-
TEST: `ConnectAndGetToken` Returns Error on Non-200 Response可能已有人在做 @aniket866 于 19 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 84/100
microcks/microcks-cli#554 ·
维护者通常 1 天内回复
查看 microcks/microcks-cli 的全部 Issue
相似的 Issue
-
agent-butler-finding chore
难度 1/5 1 小时以内 新手友好度 90/100
jordansmall/spindrift#5575 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
JakeChampion/lang#12684 ·
维护者通常 1 天内回复
-
goose sub-agent runs are never indexed: blame finds no session for any file a `delegate` child wrote未关闭bug
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
C-bug O-community X-blathers-triaged
难度 2/5 1-3 小时 新手友好度 78/100
cockroachdb/cockroach#176150 · 1 条评论 ·
维护者通常 12 天内回复
-
triage
难度 2/5 1-3 小时 新手友好度 86/100
wakatime/wakatime-cli#1649 ·
维护者通常 1 天内回复