bug: --filteredOperations fails on comma-separated list

オープン 初心者向け
#623 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 3 日以内に返信

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
65/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
go
領域
cli

調査の方向性

pkg/connectors/microcks_client.goから始めてensureValidOperationsListを読み、その後、test.mdにある--filteredOperationsの説明と関連するユニットテストを確認してください。カンマ区切りの値と単一の操作がトリミングされて変換される一方で、JSON配列入力も引き続きサポートされることを確認してください。これらのケースが通り、CLIが期待される操作リストを送信すれば完了です。

索引モデルが issue の本文から書いたものです。

説明

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!

主要言語
Go
スター
59
フォーク
75
平均マージ
7日 12時間
マージ済み PR(30日)
20

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

microcks/microcks-cli のほかの issue

microcks/microcks-cli の issue をすべて見る

似ている issue

Go の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。