Skip to content

Commit 6679cff

Browse files
authored
Update minimum Xray version requirement
Handle GitHub API error responses with detailed messages.
1 parent c160992 commit 6679cff

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

web/service/server.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,18 @@ func (s *ServerService) GetXrayVersions() ([]string, error) {
326326
}
327327
defer resp.Body.Close()
328328

329+
// Check HTTP status code - GitHub API returns object instead of array on error
330+
if resp.StatusCode != http.StatusOK {
331+
bodyBytes, _ := io.ReadAll(resp.Body)
332+
var errorResponse struct {
333+
Message string `json:"message"`
334+
}
335+
if json.Unmarshal(bodyBytes, &errorResponse) == nil && errorResponse.Message != "" {
336+
return nil, fmt.Errorf("GitHub API error: %s", errorResponse.Message)
337+
}
338+
return nil, fmt.Errorf("GitHub API returned status %d: %s", resp.StatusCode, resp.Status)
339+
}
340+
329341
buffer := bytes.NewBuffer(make([]byte, bufferSize))
330342
buffer.Reset()
331343
if _, err := buffer.ReadFrom(resp.Body); err != nil {
@@ -352,7 +364,7 @@ func (s *ServerService) GetXrayVersions() ([]string, error) {
352364
continue
353365
}
354366

355-
if major > 25 || (major == 25 && minor > 9) || (major == 25 && minor == 9 && patch >= 10) {
367+
if major > 26 || (major == 26 && minor > 1) || (major == 26 && minor == 1 && patch >= 18) {
356368
versions = append(versions, release.TagName)
357369
}
358370
}

0 commit comments

Comments
 (0)