[GH-ISSUE #4769] [Bug]: trafficDiff setting allows values above 100 in UI but backend rejects saving settings #3307

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

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

  1. Open Panel Settings.
  2. Go to Notifications.
  3. Set trafficDiff to a value greater than 100, for example 500.
  4. Try to save panel settings.
  5. The save request fails with "request body failed validation".
  6. In browser DevTools -> Network -> Response, the API returns a validation error for AllSetting.trafficDiff.

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

Browser DevTools -> Network -> 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"
  }
}

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

  • 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 @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 1. Open Panel Settings. 2. Go to Notifications. 3. Set trafficDiff to a value greater than 100, for example 500. 4. Try to save panel settings. 5. The save request fails with "request body failed validation". 6. In browser DevTools -> Network -> Response, the API returns a validation error for AllSetting.trafficDiff. ### 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 ```shell Browser DevTools -> Network -> 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" } } ``` ### 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 - [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:31:32 +07:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

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

Thanks for the detailed report — this is a confirmed bug.

Root cause: The InputNumber component for trafficDiff in the Notifications settings tab is missing a max={100} prop, so the UI happily accepts values above 100. The backend struct in web/entity/entity.go correctly enforces validate:"gte=0,lte=100", which is why saving fails.

Relevant code locations:

  • Frontend input (frontend/src/pages/settings/GeneralTab.tsx, ~line 208): only has min={0}, no max={100}
  • Frontend schema (frontend/src/schemas/setting.ts): trafficDiff is typed as nonNegativeInt.optional() with no upper-bound check
  • Generated Zod schema (frontend/src/generated/zod.ts): already has the correct z.number().int().min(0).max(100) — it's just not wired to the input
  • Backend (web/entity/entity.go): validate:"gte=0,lte=100" — correct

Fix needed:

  1. Add max={100} to the InputNumber for trafficDiff in GeneralTab.tsx
  2. Optionally update frontend/src/schemas/setting.ts to enforce the upper bound as well

A PR welcome if anyone wants to contribute this small fix!

<!-- gh-comment-id:4594013998 --> @github-actions[bot] commented on GitHub (Jun 1, 2026): Thanks for the detailed report — this is a confirmed bug. **Root cause:** The `InputNumber` component for `trafficDiff` in the Notifications settings tab is missing a `max={100}` prop, so the UI happily accepts values above 100. The backend struct in `web/entity/entity.go` correctly enforces `validate:"gte=0,lte=100"`, which is why saving fails. Relevant code locations: - **Frontend input** (`frontend/src/pages/settings/GeneralTab.tsx`, ~line 208): only has `min={0}`, no `max={100}` - **Frontend schema** (`frontend/src/schemas/setting.ts`): `trafficDiff` is typed as `nonNegativeInt.optional()` with no upper-bound check - **Generated Zod schema** (`frontend/src/generated/zod.ts`): already has the correct `z.number().int().min(0).max(100)` — it's just not wired to the input - **Backend** (`web/entity/entity.go`): `validate:"gte=0,lte=100"` — correct **Fix needed:** 1. Add `max={100}` to the `InputNumber` for `trafficDiff` in `GeneralTab.tsx` 2. Optionally update `frontend/src/schemas/setting.ts` to enforce the upper bound as well A PR welcome if anyone wants to contribute this small fix\!
Author
Owner

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

Fixed in commit 39b71640.

  • Added max={100} to the trafficDiff InputNumber in GeneralTab.tsx so the widget clamps input to the valid range.
  • Added .max(100) to trafficDiff in frontend/src/schemas/setting.ts so 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=100 constraint, resolving the misleading "request body failed validation" save failure.

<!-- gh-comment-id:4594201500 --> @MHSanaei commented on GitHub (Jun 1, 2026): Fixed in commit 39b71640. - Added `max={100}` to the `trafficDiff` `InputNumber` in `GeneralTab.tsx` so the widget clamps input to the valid range. - Added `.max(100)` to `trafficDiff` in `frontend/src/schemas/setting.ts` so 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=100` constraint, resolving the misleading "request body failed validation" save failure.
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#3307
No description provided.