Skip to content

Commit c83edaa

Browse files
authored
Fix: Latest jfrog cli version check failure (#3353)
1 parent 6793fa4 commit c83edaa

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

utils/cliutils/utils.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -652,10 +652,8 @@ func getLatestCliVersionFromGithubAPI() (githubVersionInfo githubResponse, err e
652652
if err != nil {
653653
return
654654
}
655-
// Use json.Decoder with DisallowUnknownFields for safer deserialization
656-
decoder := json.NewDecoder(bytes.NewReader(body))
657-
decoder.DisallowUnknownFields()
658-
if err = decoder.Decode(&githubVersionInfo); err != nil {
655+
// Parse the GitHub response while tolerating additional fields we do not use.
656+
if err = json.NewDecoder(bytes.NewReader(body)).Decode(&githubVersionInfo); err != nil {
659657
return
660658
}
661659
// Validate the received version tag format

utils/cliutils/utils_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ func TestAuthorizationHeaderInCliVersionCheck(t *testing.T) {
297297
// Return a valid JSON response
298298
w.Header().Set("Content-Type", "application/json")
299299
w.WriteHeader(http.StatusOK)
300-
_, err := w.Write([]byte(`{"tag_name": "v1.0.0"}`))
300+
_, err := w.Write([]byte(`{"url":"https://api.github.com/repos/jfrog/jfrog-cli/releases/1","tag_name":"v1.0.0"}`))
301301
if err != nil {
302302
return
303303
}

0 commit comments

Comments
 (0)