Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

bug: YAML parse error in config is silently swallowed, login overwrites all other contexts

Đang mở Phù hợp với người mới
#572 6 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@Sarthak-Shreshtha01 đang làm issue này rồi.

Từ ngày 8/10/2026.

  • #574 của @Sarthak-Shreshtha01 — đang mở

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
76/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
go
Lĩnh vực
cli, testing

Hướng nghiên cứu

Bắt đầu với localconfig.go quanh dòng 103 và so sánh cách ReadLocalConfig và ReadLocalWatchConfig xử lý lỗi từ configUtil.UnmarshalLocalFile. Sau đó đọc config_test.go và thêm kiểm thử YAML không hợp lệ cho cả hai hàm đọc. Hoàn thành khi lỗi phân tích cú pháp được trả về thay vì bị coi là cấu hình rỗng, trong khi tệp bị thiếu vẫn trả về nil, nil.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

component/cli kind/bug

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

  1. Put a tab on any indented line in ~/.config/microcks/config
  2. Run microcks context → reports "no contexts defined" instead of a parse error
  3. 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.

Ngôn ngữ chính
Go
Star
58
Fork
72
Merge trung bình
1 ngày 11 giờ
Pull request đã merge (30 ngày)
27

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của microcks/microcks-cli

Tất cả issue của microcks/microcks-cli

Issue tương tự

Thêm issue về Go

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.