bug: --filteredOperations fails on comma-separated list

Abierto Apto para principiantes
#623 1 comentario 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 3 días

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
65/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
go
Área
cli

Línea de trabajo

Empieza en pkg/connectors/microcks_client.go y lee ensureValidOperationsList; después, revisa la descripción de --filteredOperations en test.md y las pruebas unitarias relacionadas. Confirma que los valores separados por comas y una sola operación se recortan y se convierten, mientras que la entrada como array JSON sigue siendo compatible; el trabajo estará terminado cuando estos casos pasen y la CLI envíe la lista de operaciones esperada.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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!

Lenguaje dominante
Go
Estrellas
59
Forks
75
Merge medio
7 d 12 h
PR fusionados (30 d)
20

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de microcks/microcks-cli

Todos los issues de microcks/microcks-cli

Issues similares

Más issues de Go

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.