fix: return errors instead of panicking on response parsing in connectors#319
Open
Git-HimanshuRathi wants to merge 1 commit intomicrocks:masterfrom
Open
fix: return errors instead of panicking on response parsing in connectors#319Git-HimanshuRathi wants to merge 1 commit intomicrocks:masterfrom
Git-HimanshuRathi wants to merge 1 commit intomicrocks:masterfrom
Conversation
|
Welcome to the Microcks community! 💖 Thanks and congrats 🎉 for opening your first pull request here! Be sure to follow the pull request template or please update it accordingly. Hope you have a great time there! |
…tors Replace panic(err) / panic(err.Error()) calls in microcks_client.go and keycloak_client.go with wrapped fmt.Errorf returns. All affected methods already declared error in their return signature, so panicking on io.ReadAll, json.Unmarshal, or io.Copy failure crashed the CLI instead of surfacing a clean error to the user. Continues the pattern from microcks#258, microcks#259, and f9f282c. Signed-off-by: Git-HimanshuRathi <[email protected]>
28fffb3 to
126f5dd
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replaces 12 panic(err) / panic(err.Error()) calls in pkg/connectors/{microcks,keycloak}_client.go with wrapped fmt.Errorf("...: %w", err) returns.
Cleans up three return x, err sites where err was guaranteed nil after the change (now return x, nil).
Continues the pattern established by #258, #259 and commit f9f282c, which fixed the same anti-pattern in one location each.
fixes #318
Why
Every affected method already returns error. Panicking on io.ReadAll / json.Unmarshal / io.Copy failure means a malformed or truncated response from Microcks/Keycloak crashes the CLI with a stack trace instead of surfacing a clean error. This is most visible when a reverse proxy or gateway returns HTML on an otherwise-2xx request, or when the connection drops mid-body.
Test plan