id_formats: plain-form ids still accept empty parts (follow-up to #432)

Đang mở Phù hợp với người mới
#587 0 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

Chưa có ai nhận issue này.

Đá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
79/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

Hướng nghiên cứu

Đọc pkg/spec/idformat.go và các bài kiểm thử của ParseId, lấy trường hợp tái hiện trong source/ làm điểm bắt đầu. Đảm bảo dạng đơn giản từ chối dấu gạch chéo ở đầu, ở cuối và lặp lại, đồng thời giữ nguyên dạng JSON cho các phần rỗng. Công việc hoàn tất khi các trường hợp đó trả về lỗi hữu ích và các định dạng hợp lệ hiện có vẫn vượt qua bài kiểm thử.

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

Mô tả

spec.ParseId still accepts empty segments in plain-form ids, so an incomplete id is sent to the server instead of failing in the CLI. #432 describes the same problem and proposed the fix, but it was closed without a change: pkg/spec/idformat.go on main has no empty-part check.

Repro

list scs_component uses id_formats: ["<source>/<artifact>", "<artifact>"]:

$ harness list scs_component <source_id>/ --debug
POST .../artifacts//components   ->   API error 404: HTTP 404 Not Found

source/ matches the two-part format with artifact="", so the path template renders artifacts//components. The user gets a bare 404 with no hint that the id was incomplete. The same applies to every format that has a fixed part, e.g. <repo>/<pr> with r/.

Proposed fix

As in #432: in the plain form, ParseId rejects a leading /, a trailing / and //, with an error such as id "reg/" has an empty part; pass the parts exactly as a JSON array. The JSON form stays as the escape hatch for genuinely empty parts.

Context

Raised in review of the SCS component commands (#582), and also relevant to the id_formats change in #583.

Ngôn ngữ chính
Go
Star
29
Fork
24
Merge trung bình
1 ngày 9 giờ
Pull request đã merge (30 ngày)
111

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 harness/cli

Tất cả issue của harness/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.