[PR #3609] [MERGED] fix: handle GitHub API error responses in GetXrayVersions #5483

Closed
opened 2026-10-31 20:47:17 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/MHSanaei/3x-ui/pull/3609
Author: @qzydustin
Created: 12/26/2025
Status: ✅ Merged
Merged: 1/2/2026
Merged by: @MHSanaei

Base: main ← Head: main


📝 Commits (1)

  • cc3e6d4 fix: handle GitHub API error responses in GetXrayVersions

📊 Changes

1 file changed (+12 additions, -0 deletions)

View changed files

📝 web/service/server.go (+12 -0)

📄 Description

GitHub API returns JSON object instead of array when encountering errors (e.g., rate limit exceeded). This causes JSON unmarshal error: 'cannot unmarshal object into Go value of type []service.Release'

Add HTTP status code check to handle error responses gracefully and return user-friendly error messages instead of JSON parsing errors.

Fixes issue where getXrayVersion fails with unmarshal error when GitHub API rate limit is exceeded.

What is the pull request?

This PR fixes a bug in GetXrayVersions() function where GitHub API error responses (e.g., rate limit exceeded) cause JSON unmarshal errors. When GitHub API returns an error (status code 403, etc.), it returns a JSON object instead of an array, causing the code to fail with "cannot unmarshal object into Go value of type []service.Release".

The fix adds HTTP status code validation before parsing the response. When a non-200 status is detected, the code now reads and parses the error message from the response body, returning a user-friendly error message instead of a JSON parsing error.

Which part of the application is affected by the change?

  • Frontend
  • Backend

Type of Changes

  • Bug fix
  • New feature
  • Refactoring
  • Other

Screenshots

image

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/MHSanaei/3x-ui/pull/3609 **Author:** [@qzydustin](https://github.com/qzydustin) **Created:** 12/26/2025 **Status:** ✅ Merged **Merged:** 1/2/2026 **Merged by:** [@MHSanaei](https://github.com/MHSanaei) **Base:** `main` ← **Head:** `main` --- ### 📝 Commits (1) - [`cc3e6d4`](https://github.com/MHSanaei/3x-ui/commit/cc3e6d45bab99fbf79f11de8f9c7d6298f72aa08) fix: handle GitHub API error responses in GetXrayVersions ### 📊 Changes **1 file changed** (+12 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `web/service/server.go` (+12 -0) </details> ### 📄 Description GitHub API returns JSON object instead of array when encountering errors (e.g., rate limit exceeded). This causes JSON unmarshal error: 'cannot unmarshal object into Go value of type []service.Release' Add HTTP status code check to handle error responses gracefully and return user-friendly error messages instead of JSON parsing errors. Fixes issue where getXrayVersion fails with unmarshal error when GitHub API rate limit is exceeded. ## What is the pull request? This PR fixes a bug in `GetXrayVersions()` function where GitHub API error responses (e.g., rate limit exceeded) cause JSON unmarshal errors. When GitHub API returns an error (status code 403, etc.), it returns a JSON object instead of an array, causing the code to fail with "cannot unmarshal object into Go value of type []service.Release". The fix adds HTTP status code validation before parsing the response. When a non-200 status is detected, the code now reads and parses the error message from the response body, returning a user-friendly error message instead of a JSON parsing error. ## Which part of the application is affected by the change? - [ ] Frontend - [x] Backend ## Type of Changes - [x] Bug fix - [ ] New feature - [ ] Refactoring - [ ] Other ## Screenshots <img width="600" height="52" alt="image" src="https://github.com/user-attachments/assets/5ebe3709-9463-4ab9-bb5f-e61b789b7202" /> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-31 20:47:17 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
MHSanaei/3x-ui#5483
No description provided.