mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[GH-ISSUE #5516] [Bug]: Invalid value error for empty rewrite port field in tunnel inbound #3851
Labels
No labels
backlog
bug
clarification needed
documentation
duplicate
enhancement
github_actions
good first issue
invalid
javascript
New Feature
PR welcomed
pull-request
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
MHSanaei/3x-ui#3851
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @DenMaxRus on GitHub (Jun 23, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/5516
Describe the bug
When typing
rewritePortin tunnel inbound, then removing it, json contains"rewritePort": nulland on save ui showssettings.rewritePort — Invalid inputerror. You need to manually remove the wholerewritePortto fix itHow to reproduce the problem
Rewrite portfield to some value, e.g.12345Rewrite portfieldExpected behavior
Json doesn't contain
rewritePortORrewritePortvalue is 0. https://xtls.github.io/en/config/inbounds/tunnel.html#inboundconfigurationobjectActual behavior
Json contains
"rewritePort": nulland on save ui showssettings.rewritePort — Invalid inputerror, can't save.Relevant logs
Screenshots
3x-ui version
3.3.1,3.4.0
Xray-core version
26.6.22
How did you install 3x-ui?
Docker / Docker Compose
Operating system
Ubuntu 24.04
Which parts of the panel are affected?
Frontend (UI / panel pages), Xray config generation
Browser (only if it is a UI bug)
No response
Is the panel behind a reverse proxy or CDN?
Yes — Nginx
Before submitting
@github-actions[bot] commented on GitHub (Jun 23, 2026):
This is a confirmed bug in the frontend schema. The root cause is a type mismatch between what Ant Design's
InputNumberemits when cleared and what the Zod schema accepts.What happens step by step
Rewrite portfield, Ant Design'sInputNumberwritesnullinto the form store — that is its standard behavior for an empty numeric field."rewritePort": null.InboundFormModal.tsx(line 464) runsInboundFormSchema.safeParse(values).frontend/src/schemas/protocols/inbound/tunnel.tsdeclares: wherePortSchema(infrontend/src/schemas/primitives/port.ts) is:.optional()permitsundefinedbut notnull. The form store value isnull, so Zod rejects it with "Invalid input" at pathsettings.rewritePort.formatInboundValidationinfrontend/src/pages/inbounds/form/formatValidationError.tsformats this as thesettings.rewritePort — Invalid inputtoast the reporter sees.Why the workaround works
Manually deleting the
rewritePortkey from the JSON editor sets the form store value toundefined, which.optional()does accept.Correct fix (for contributors)
In
frontend/src/schemas/protocols/inbound/tunnel.ts, change therewritePortfield to accept and normalizenull:nullish()is equivalent to.nullable().optional()— it accepts bothnullandundefined. The.transform()collapsesnulltoundefinedso the field is omitted from the serialized payload (matching the expected behavior described in the issue) rather than sent asnull.A secondary inconsistency:
PortSchemaenforcesmin(1), but theInputNumberinfrontend/src/pages/inbounds/form/protocols/tunnel.tsxrenders withmin={0}. Xray's tunnel docs state thatrewritePort: 0means "do not rewrite", soPortSchema.nullish()should arguably usez.number().int().min(0).max(65535)— but that is separate from the crash reported here.Affected versions: confirmed present in v3.3.1 and v3.4.0 (current release).
This reply was generated automatically by the issue-triage assistant; a maintainer may follow up.