config validate: detect bare/null unsupported sections (true key-presence)
@shreemaan-abhishek đang làm issue này rồi.
Từ ngày 18/5/2026.
- #44 của @shreemaan-abhishek — đã đóng, không merge
Đánh giá
Issue này chưa được đánh giá.
Mô tả
Part of #22. Follow-up to review feedback on #31.
Problem
The current cfg.<Section> != nil check in pkg/cmd/config/validate/validate.go and pkg/cmd/config/configutil/configutil.go only rejects explicitly-empty unsupported sections (e.g. upstreams: []). It does not reject:
upstreams:(bare key, no value) — unmarshals tonilupstreams: null— unmarshals tonil
Same for consumer_groups and service_templates. A user who declares any of these forms gets silent acceptance.
Fix
Two-pass parse: first into map[string]yaml.Node (or map[string]json.RawMessage for JSON), check whether the key is present at all, then decode into the typed api.ConfigFile. If a key for an unsupported section is present, reject regardless of value.
Tests
Extend TestConfigValidate_EmptyUnsupportedSections (or add a sibling table) with cases:
upstreams:(no value)upstreams: nullconsumer_groups:/consumer_groups: nullservice_templates:/service_templates: null
All should produce the same "X are not supported" error as the existing [] cases.
- Ngôn ngữ chính
- Go
- Star
- 1
- Fork
- 0
- Merge trung bình
- 1 giờ 3 phút
- Pull request đã merge (30 ngày)
- 1
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Không có hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của api7/a7
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
Issue tương tự
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Gentleman-Programming/engram#1899 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
OpenTollGate/tollgate-module-basic-go#949 ·
Maintainer thường phản hồi trong vòng 1 ngày