Skip to content

Conversation

@tarmo-randma
Copy link
Collaborator

No description provided.

Copy link

Copilot AI left a 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 JwtTokenSafeResponse struct with json.RawMessage for the Records field to defer parsing
  • Refactors both GetJWTToken methods (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.

Copy link

Copilot AI commented Jan 30, 2026

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants