Bug description
Several methods in pkg/connectors/microcks_client.go and pkg/connectors/keycloak_client.go call panic() when io.ReadAll or json.Unmarshal fail on an HTTP response. Because every one of these methods already has error in its return signature, panicking instead of returning the error means any malformed/truncated response from the Microcks server or Keycloak crashes the entire CLI with a stack trace, instead of producing a clean user-facing error.
This is the same anti-pattern that was previously fixed in:
#258 (json.Unmarshal ignored in GetTestResult)
#259 (DownloadArtifact not reading body)
f9f282c (replaced one panic in GetTestResult with a wrapped error)
The recent f9f282c only fixed a single occurrence. The same panic(err) / panic(err.Error()) pattern still exists in 11 other places.
Reproduction
Any scenario where the Microcks or Keycloak server returns a non-JSON body (HTML error page from a reverse proxy, truncated body on connection drop, gateway timeout HTML, etc.) on an otherwise-2xx-coded request will crash the CLI with a Go panic stack trace instead of a friendly error.
Proposed fix
Replace each panic(err) / panic(err.Error()) with a wrapped fmt.Errorf("...: %w", err) return, matching the style of the recent fix at microcks_client.go:413-415.
Bug description
Several methods in pkg/connectors/microcks_client.go and pkg/connectors/keycloak_client.go call panic() when io.ReadAll or json.Unmarshal fail on an HTTP response. Because every one of these methods already has error in its return signature, panicking instead of returning the error means any malformed/truncated response from the Microcks server or Keycloak crashes the entire CLI with a stack trace, instead of producing a clean user-facing error.
This is the same anti-pattern that was previously fixed in:
#258 (json.Unmarshal ignored in GetTestResult)
#259 (DownloadArtifact not reading body)
f9f282c (replaced one panic in GetTestResult with a wrapped error)
The recent f9f282c only fixed a single occurrence. The same panic(err) / panic(err.Error()) pattern still exists in 11 other places.
Reproduction
Any scenario where the Microcks or Keycloak server returns a non-JSON body (HTML error page from a reverse proxy, truncated body on connection drop, gateway timeout HTML, etc.) on an otherwise-2xx-coded request will crash the CLI with a Go panic stack trace instead of a friendly error.
Proposed fix
Replace each panic(err) / panic(err.Error()) with a wrapped fmt.Errorf("...: %w", err) return, matching the style of the recent fix at microcks_client.go:413-415.