Skip to content

fix: handle HTML responses in panel management API requests#12264

Open
jakub961241 wants to merge 1 commit into1Panel-dev:dev-v2from
jakub961241:fix/panel-json-unmarshal-12260
Open

fix: handle HTML responses in panel management API requests#12264
jakub961241 wants to merge 1 commit into1Panel-dev:dev-v2from
jakub961241:fix/panel-json-unmarshal-12260

Conversation

@jakub961241
Copy link

Summary

Fixes #12260 - Multi-machine management fails when adding a panel with error:

load current config failed, err: json umarshal resp data failed, err: invalid character '<' looking for beginning of value

Root Cause

When the remote panel returns a 401 Unauthorized response, it sends an HTML page (401.html) with Content-Type: text/html. The code at core/utils/req_helper/proxy_local/req_to_local.go attempted to json.Unmarshal() this HTML, causing the invalid character '<' error.

Fix

  • Add explicit 401 Unauthorized handling with a clear error message
  • Validate Content-Type header is JSON before attempting unmarshal
  • Include response preview in error messages for easier debugging
  • Read body before status check so error messages can include response content

Changed file

  • core/utils/req_helper/proxy_local/req_to_local.go
fix: Fix multi-machine panel management failing with JSON unmarshal error when remote panel returns HTML response (#12260)

…ev#12260)

When adding a remote panel, the API may return HTML (e.g., 401 login
page) instead of JSON. The code attempted to unmarshal HTML as JSON,
causing: "json umarshal resp data failed, err: invalid character '<'"

Changes:
- Read response body before status check to include it in errors
- Add explicit 401 Unauthorized handling with clear error message
- Validate Content-Type is JSON before attempting unmarshal
- Include response preview in error for easier debugging

Fixes 1Panel-dev#12260
@f2c-ci-robot
Copy link

f2c-ci-robot bot commented Mar 21, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign wanghe-fit2cloud for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Multi-machine management exception

1 participant