bug: --filteredOperations fails on comma-separated list

Đang mở Phù hợp với người mới
#623 1 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 3 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
65/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

Bắt đầu từ pkg/connectors/microcks_client.go và đọc ensureValidOperationsList, sau đó kiểm tra phần mô tả --filteredOperations trong test.md cùng các unit test liên quan. Xác nhận rằng các giá trị phân tách bằng dấu phẩy và một operation đơn lẻ được loại bỏ khoảng trắng thừa và chuyển đổi, trong khi đầu vào dạng JSON array vẫn được hỗ trợ; công việc hoàn tất khi các trường hợp này chạy qua và CLI gửi danh sách operation như mong đợi.

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

Mô tả

Describe the bug

While trying to run tests on specific operations using --filteredOperations, I noticed that passing a comma-separated list (or even a single operation) like --filteredOperations "GET /pastries,POST /pastries" fails immediately:

creating test: parsing filteredOperations JSON: invalid character 'G' looking for beginning of value

The docs in test.md mention that --filteredOperations accepts a "Comma-separated list of operations to test", but ensureValidOperationsList in pkg/connectors/microcks_client.go runs a direct json.Unmarshal on the string.

So right now it only works if you pass a raw JSON array string like '["GET /pastries"]', which is pretty unintuitive for a CLI flag and contradicts what the docs say.

Expected behavior

It should accept normal comma-separated strings like --filteredOperations "GET /pastries, POST /pastries" (and single operations like "GET /pastries"), trim whitespace, and turn that into the array payload for the server.

Keeping support for the ["..."] JSON array format would also be good so we don't break anyone already passing JSON.

Actual behavior
$ microcks test "hello:1.0" "http://localhost:8080" HTTP --filteredOperations "GET /hello,POST /hello" --microcksURL http://127.0.0.1:8888
creating test: parsing filteredOperations JSON: invalid character 'G' looking for beginning of value
exit status 2
How to Reproduce?

Run a test passing a comma-separated list to --filteredOperations:

microcks test "MyAPI:1.0" "http://localhost:8080" HTTP --filteredOperations "GET /pastries,POST /pastries" --microcksURL http://127.0.0.1:8888

It fails with the JSON parse error.

Microcks version or git rev

main

Install method (docker-compose, helm chart, operator, docker-desktop extension,...)

cli

Additional information

The fix is pretty straightforward in pkg/connectors/microcks_client.go, if the string doesn't start with [, we can just split on commas, trim spaces, and marshal the slice to JSON.

Tested this locally and happy to open a quick PR with the fix and unit tests if that sounds good!

Ngôn ngữ chính
Go
Star
59
Fork
75
Merge trung bình
7 ngày 12 giờ
Pull request đã merge (30 ngày)
20

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.