bug: --filteredOperations fails on comma-separated list

Aberta Para iniciantes
#623 1 comentário 0 reações 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 3 dias

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
2/5
Tempo estimado
1-3 horas
Facilidade para iniciantes
65/100
Tipo de issue
Bug
Clareza
Claramente especificada
Status de atividade
Ativa
Stack de tecnologia
go
Domínio
cli

Direção de pesquisa

Comece em pkg/connectors/microcks_client.go e leia ensureValidOperationsList; em seguida, confira a descrição de --filteredOperations em test.md e os testes unitários relacionados. Confirme que valores separados por vírgula e uma única operação são removidos de espaços extras e convertidos, enquanto a entrada como array JSON continua sendo compatível; o trabalho estará concluído quando esses casos passarem e a CLI enviar a lista de operações esperada.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

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!

Linguagem predominante
Go
Estrelas
59
Forks
75
Merge médio
7d 12h
PRs com merge (30d)
20

Preparar o ambiente

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de microcks/microcks-cli

Todas as issues de microcks/microcks-cli

Issues semelhantes

Mais issues de Go

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.