mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[GH-ISSUE #4769] [Bug]: trafficDiff setting allows values above 100 in UI but backend rejects saving settings #3307
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#3307
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 @AlexeysM14 on GitHub (Jun 1, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/4769
Describe the bug
The Panel Settings page allows entering a trafficDiff value greater than 100, but the backend validation rejects the whole settings save request with "request body failed validation".
This makes it look like panel settings cannot be saved at all, while the actual problem is only the trafficDiff field.
Backend validation correctly limits trafficDiff to 0..100, but the frontend input does not seem to enforce max=100.
How to reproduce the problem
Expected behavior
The UI should prevent entering values above 100 for trafficDiff, or show a clear field-level validation message before sending the request.
Actual behavior
The panel allows entering a value above 100, but saving settings fails with the following response:
{
"success": false,
"msg": "request body failed validation",
"obj": {
"issues": [
{
"field": "trafficDiff",
"rule": "lte",
"param": "100",
"message": "Key: 'AllSetting.trafficDiff' Error:Field validation for 'trafficDiff' failed on the 'lte' tag"
}
],
"message": "Key: 'AllSetting.trafficDiff' Error:Field validation for 'trafficDiff' failed on the 'lte' tag"
}
}
Relevant logs
Screenshots
No response
3x-ui version
3.2.5
Xray-core version
26.6.1
How did you install 3x-ui?
install.sh script
Operating system
Ubuntu 24.04
Which parts of the panel are affected?
Frontend (UI / panel pages)
Browser (only if it is a UI bug)
Chrome on macOS
Is the panel behind a reverse proxy or CDN?
None
Before submitting
@github-actions[bot] commented on GitHub (Jun 1, 2026):
Thanks for the detailed report — this is a confirmed bug.
Root cause: The
InputNumbercomponent fortrafficDiffin the Notifications settings tab is missing amax={100}prop, so the UI happily accepts values above 100. The backend struct inweb/entity/entity.gocorrectly enforcesvalidate:"gte=0,lte=100", which is why saving fails.Relevant code locations:
frontend/src/pages/settings/GeneralTab.tsx, ~line 208): only hasmin={0}, nomax={100}frontend/src/schemas/setting.ts):trafficDiffis typed asnonNegativeInt.optional()with no upper-bound checkfrontend/src/generated/zod.ts): already has the correctz.number().int().min(0).max(100)— it's just not wired to the inputweb/entity/entity.go):validate:"gte=0,lte=100"— correctFix needed:
max={100}to theInputNumberfortrafficDiffinGeneralTab.tsxfrontend/src/schemas/setting.tsto enforce the upper bound as wellA PR welcome if anyone wants to contribute this small fix!
@MHSanaei commented on GitHub (Jun 1, 2026):
Fixed in commit
39b71640.max={100}to thetrafficDiffInputNumberinGeneralTab.tsxso the widget clamps input to the valid range..max(100)totrafficDiffinfrontend/src/schemas/setting.tsso client-side validation surfaces a clear field-level error instead of letting an out-of-range value reach the backend.The UI now matches the backend's
gte=0,lte=100constraint, resolving the misleading "request body failed validation" save failure.