[PR #5162] [CLOSED] Fix Clear Offline button: return 204 No Content for nil API responses #5152

Closed
opened 2026-05-05 14:55:40 -06:00 by gitea-mirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/fatedier/frp/pull/5162
Author: @Copilot
Created: 2/6/2026
Status: Closed

Base: devHead: copilot/investigate-issue-5160


📝 Commits (4)

  • c227b6a Initial plan
  • e2ce728 Fix Clear Offline button: return 204 No Content for nil API responses
  • 6692dac Final status update
  • 3115399 Revert accidental package-lock.json changes from CodeQL scan

📊 Changes

2 files changed (+71 additions, -1 deletions)

View changed files

📝 pkg/util/http/handler.go (+1 -1)
pkg/util/http/handler_test.go (+70 -0)

📄 Description

WHY

The "Clear Offline" button in the server dashboard fails with "Failed to execute 'json' on 'Response': Unexpected end of JSON input".

DeleteProxies returns (nil, nil)MakeHTTPHandlerFunc sends 200 with empty body → frontend calls response.json() on empty body → parse error.

Fix: Return 204 No Content instead of 200 OK when the handler result is nil. The frontend already handles 204 correctly:

if (response.status === 204) {
  return {} as T
}
  • pkg/util/http/handler.goStatusOKStatusNoContent for nil responses
  • pkg/util/http/handler_test.go — tests for nil, struct, and error response paths

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.


🔄 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/fatedier/frp/pull/5162 **Author:** [@Copilot](https://github.com/apps/copilot-swe-agent) **Created:** 2/6/2026 **Status:** ❌ Closed **Base:** `dev` ← **Head:** `copilot/investigate-issue-5160` --- ### 📝 Commits (4) - [`c227b6a`](https://github.com/fatedier/frp/commit/c227b6a500d59bc71ce30df0a0b2d05b513ed0e0) Initial plan - [`e2ce728`](https://github.com/fatedier/frp/commit/e2ce7286b637454280bd54380068ee5e9285298f) Fix Clear Offline button: return 204 No Content for nil API responses - [`6692dac`](https://github.com/fatedier/frp/commit/6692dace1fc831ffdcf0cc59063ae0be87cac46a) Final status update - [`3115399`](https://github.com/fatedier/frp/commit/31153995f655315522c08c7550a00a7cfe502527) Revert accidental package-lock.json changes from CodeQL scan ### 📊 Changes **2 files changed** (+71 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `pkg/util/http/handler.go` (+1 -1) ➕ `pkg/util/http/handler_test.go` (+70 -0) </details> ### 📄 Description ### WHY The "Clear Offline" button in the server dashboard fails with `"Failed to execute 'json' on 'Response': Unexpected end of JSON input"`. `DeleteProxies` returns `(nil, nil)` → `MakeHTTPHandlerFunc` sends 200 with empty body → frontend calls `response.json()` on empty body → parse error. **Fix:** Return `204 No Content` instead of `200 OK` when the handler result is nil. The frontend already handles 204 correctly: ```typescript if (response.status === 204) { return {} as T } ``` - `pkg/util/http/handler.go` — `StatusOK` → `StatusNoContent` for nil responses - `pkg/util/http/handler_test.go` — tests for nil, struct, and error response paths <!-- START COPILOT CODING AGENT TIPS --> --- 💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more [Copilot coding agent tips](https://gh.io/copilot-coding-agent-tips) in the docs. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
gitea-mirror 2026-05-05 14:55:40 -06: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: github-starred/frp#5152
No description provided.