bug: --filteredOperations fails on comma-separated list

Offen Anfängerfreundlich
#623 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 3 Tagen

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
2/5
Geschätzter Aufwand
1-3 Stunden
Anfängerfreundlichkeit
65/100
Issue-Typ
Bug
Klarheit
Klar beschrieben
Aktivitätsstatus
Aktiv
Tech-Stack
go
Bereich
cli

Rechercherichtung

Beginne in pkg/connectors/microcks_client.go und lies ensureValidOperationsList, prüfe dann die Beschreibung von --filteredOperations in test.md und die zugehörigen Unit-Tests. Bestätige, dass durch Kommas getrennte Werte und eine einzelne Operation getrimmt und konvertiert werden, während die Eingabe als JSON-Array weiterhin unterstützt wird; fertig ist die Aufgabe, wenn diese Fälle bestehen und die CLI die erwartete Operationsliste sendet.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

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!

Vorherrschende Sprache
Go
Sterne
59
Forks
75
Ø Merge
7 T. 12 Std.
Gemergte PRs (30 T.)
20

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus microcks/microcks-cli

Alle Issues in microcks/microcks-cli

Ähnliche Issues

Weitere Issues zu Go

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.