[GH-ISSUE #4856] [Bug]: Can't add external nodes #3387

Closed
opened 2026-10-31 20:32:05 +07:00 by bsakaguchi · 3 comments
Owner

Originally created by @MACTEP434 on GitHub (Jun 3, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/4856

Describe the bug

When i add external node, test connection is ok but when push save i have error message "invalid input"

How to reproduce the problem

  1. Open nodes page
  2. Add node
  3. Fill in real data
  4. push Save

Expected behavior

No response

Actual behavior

No response

Relevant logs


Screenshots

No response

3x-ui version

3.2.6

Xray-core version

26.6.1

How did you install 3x-ui?

Docker / Docker Compose

Operating system

Debian 13

Which parts of the panel are affected?

No response

Browser (only if it is a UI bug)

No response

Is the panel behind a reverse proxy or CDN?

None

Before submitting

  • I searched existing issues and this bug has not been reported.
  • I am running the latest released version of 3x-ui (or have verified the bug still exists on it).
  • This bug report is written in English.
  • I have redacted any sensitive data (tokens, real domains, client UUIDs).
Originally created by @MACTEP434 on GitHub (Jun 3, 2026). Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/4856 ### Describe the bug When i add external node, test connection is ok but when push save i have error message "invalid input" ### How to reproduce the problem 1. Open nodes page 2. Add node 3. Fill in real data 4. push Save ### Expected behavior _No response_ ### Actual behavior _No response_ ### Relevant logs ```shell ``` ### Screenshots _No response_ ### 3x-ui version 3.2.6 ### Xray-core version 26.6.1 ### How did you install 3x-ui? Docker / Docker Compose ### Operating system Debian 13 ### Which parts of the panel are affected? _No response_ ### Browser (only if it is a UI bug) _No response_ ### Is the panel behind a reverse proxy or CDN? None ### Before submitting - [x] I searched [existing issues](../issues?q=is%3Aissue) and this bug has not been reported. - [x] I am running the latest released version of 3x-ui (or have verified the bug still exists on it). - [x] This bug report is written in English. - [x] I have redacted any sensitive data (tokens, real domains, client UUIDs).
bsakaguchi 2026-10-31 20:32:05 +07:00
Author
Owner

@github-actions[bot] commented on GitHub (Jun 3, 2026):

Thanks for the report.

What's happening under the hood

The Test Connection button only validates the address and port fields before hitting POST /panel/api/nodes/test, which does a bare bind with no struct validation. The node can be probed successfully without an API token — Probe() sends the Authorization header only if the token is non-empty (web/service/node.go:496-498).

The Save button goes through a stricter path:

  1. Frontend runs NodeFormSchema.safeParse() plus Ant Design field validators on all fields.
  2. Backend BindAndValidate[model.Node] (web/middleware/validate.go) enforces struct tags:
    • name: required
    • address: required
    • port: must be 1-65535
    • apiToken: required
    • scheme: if non-empty, must be http or https
    • tlsVerifyMode: if non-empty, must be verify, skip, or pin
  3. Backend nodeService.normalize() validates hostname format via a strict regex (letters, digits, hyphens, dots only — underscores, bare colons, or a port suffix like 1.2.3.4:2053 in the address field are all rejected).
  4. Backend ensureReachable() probes the node again with the submitted API token.

When validation fails, the backend returns { success: false, msg: 'request body failed validation', obj: { issues: [...] } }. The frontend shows the msg value as an error toast — that is likely the error you are seeing.

How to find the exact cause

  1. Open browser DevTools (F12) and go to the Network tab.
  2. Click Save again.
  3. Find the POST /panel/api/nodes/add (or update/:id) request and open its Response.
  4. The obj.issues array names the exact field and rule that failed, for example: field=apiToken, rule=required.

Most common causes for test-passes-but-save-fails

  • API token empty or wrong — Probe() sends the Authorization: Bearer header only if the token field is non-empty, so a test against a remote panel that does not enforce auth can return online even with a blank token. The save endpoint requires apiToken (validate:required in database/model/model.go). Fix: on the remote panel go to Settings > API > Generate Token, copy the token, and paste it into the API Token field in the node form.
  • Port cleared to 0 — the backend gte=1 check fails if port is zero.
  • Address contains disallowed characters — underscores (my_server.host), a port suffix in the address field (1.2.3.4:2053), or bare IPv6 without square brackets are rejected by netsafe.NormalizeHost. Enter only the hostname or IP in the Address field; put the port in the separate Port field.

Could you paste the full JSON response body from the failed POST /panel/api/nodes/add request (Network tab > Response)? That will show exactly which field is being rejected.

<!-- gh-comment-id:4611812984 --> @github-actions[bot] commented on GitHub (Jun 3, 2026): Thanks for the report. **What's happening under the hood** The **Test Connection** button only validates the address and port fields before hitting POST /panel/api/nodes/test, which does a bare bind with no struct validation. The node can be probed successfully without an API token — Probe() sends the Authorization header only if the token is non-empty (web/service/node.go:496-498). The **Save** button goes through a stricter path: 1. Frontend runs NodeFormSchema.safeParse() plus Ant Design field validators on all fields. 2. Backend BindAndValidate[model.Node] (web/middleware/validate.go) enforces struct tags: - name: required - address: required - port: must be 1-65535 - apiToken: required - scheme: if non-empty, must be http or https - tlsVerifyMode: if non-empty, must be verify, skip, or pin 3. Backend nodeService.normalize() validates hostname format via a strict regex (letters, digits, hyphens, dots only — underscores, bare colons, or a port suffix like 1.2.3.4:2053 in the address field are all rejected). 4. Backend ensureReachable() probes the node again with the submitted API token. When validation fails, the backend returns { success: false, msg: 'request body failed validation', obj: { issues: [...] } }. The frontend shows the msg value as an error toast — that is likely the error you are seeing. **How to find the exact cause** 1. Open browser DevTools (F12) and go to the Network tab. 2. Click Save again. 3. Find the POST /panel/api/nodes/add (or update/:id) request and open its Response. 4. The obj.issues array names the exact field and rule that failed, for example: field=apiToken, rule=required. **Most common causes for test-passes-but-save-fails** - **API token empty or wrong** — Probe() sends the Authorization: Bearer header only if the token field is non-empty, so a test against a remote panel that does not enforce auth can return online even with a blank token. The save endpoint requires apiToken (validate:required in database/model/model.go). Fix: on the remote panel go to Settings > API > Generate Token, copy the token, and paste it into the API Token field in the node form. - **Port cleared to 0** — the backend gte=1 check fails if port is zero. - **Address contains disallowed characters** — underscores (my_server.host), a port suffix in the address field (1.2.3.4:2053), or bare IPv6 without square brackets are rejected by netsafe.NormalizeHost. Enter only the hostname or IP in the Address field; put the port in the separate Port field. Could you paste the full JSON response body from the failed POST /panel/api/nodes/add request (Network tab > Response)? That will show exactly which field is being rejected.
Author
Owner

@Dronneo commented on GitHub (Jun 3, 2026):

Такое же поведение на Ubuntu 24. У меня решилось сменой "проверка TLS" с "Проверять (стандартный СА)" на "Закрепить сертификат (SHA-256)" и дальнейшим нажатием "Получить".

<!-- gh-comment-id:4611836297 --> @Dronneo commented on GitHub (Jun 3, 2026): Такое же поведение на Ubuntu 24. У меня решилось сменой "проверка TLS" с "Проверять (стандартный СА)" на "Закрепить сертификат (SHA-256)" и дальнейшим нажатием "Получить".
Author
Owner

@MHSanaei commented on GitHub (Jun 3, 2026):

Duplicate
Already fixed

<!-- gh-comment-id:4612067383 --> @MHSanaei commented on GitHub (Jun 3, 2026): Duplicate Already fixed
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#3387
No description provided.