-
Notifications
You must be signed in to change notification settings - Fork 9
Fix for parsing GetJWTToken response in case of an error #136
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR fixes a parsing issue in the GetJWTToken methods that occurred when the API returned an error response. The fix implements a two-stage JSON parsing approach using json.RawMessage to safely handle error responses where the records field may not match the expected JwtToken structure.
Changes:
- Introduces
JwtTokenSafeResponsestruct withjson.RawMessagefor the Records field to defer parsing - Refactors both
GetJWTTokenmethods (for Client and PartnerClient) to first check response status before attempting to unmarshal records - Removes an unrelated backup file (models.go.bak) from the servicediscovery package
- Improves comment formatting to follow Go conventions (adding spaces after
//)
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 8 comments.
| File | Description |
|---|---|
| pkg/api/servicediscovery/models.go.bak | Removes backup file that should not be in version control |
| pkg/api/auth/tokenRequsts.go | Refactors GetJWTToken methods to use two-stage parsing and improves comment formatting |
| pkg/api/auth/models.go | Adds JwtTokenSafeResponse struct with json.RawMessage for safe error handling |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@tarmo-randma I've opened a new pull request, #137, to work on those changes. Once the pull request is ready, I'll request review from you. |
No description provided.