[GH-ISSUE #5298] [Bug]: Subscription sort order not working #3711

Closed
opened 2026-10-31 20:34:24 +07:00 by bsakaguchi · 1 comment
Owner

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

Describe the bug

subscription sort order is not working properly and every time you close the modify inbound windows it resets to 1 which is the default value, surprisingly some inbounds keep the value somehow but others don't

How to reproduce the problem

open edit an inbound
change the sort value to sth else rather than 1
save and close
reopen the edit window
value is set back to 1

Expected behavior

No response

Actual behavior

No response

Relevant logs


Screenshots

No response

3x-ui version

v3.3.1

Xray-core version

v26.6.1

How did you install 3x-ui?

install.sh script

Operating system

Ubuntu 24

Which parts of the panel are affected?

Frontend (UI / panel pages), Backend (API endpoints, login, settings)

Browser (only if it is a UI bug)

Chrome latest version

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 @AmirSalar-Yn on GitHub (Jun 13, 2026). Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/5298 ### Describe the bug subscription sort order is not working properly and every time you close the modify inbound windows it resets to 1 which is the default value, surprisingly some inbounds keep the value somehow but others don't ### How to reproduce the problem open edit an inbound change the sort value to sth else rather than 1 save and close reopen the edit window value is set back to 1 ### Expected behavior _No response_ ### Actual behavior _No response_ ### Relevant logs ```shell ``` ### Screenshots _No response_ ### 3x-ui version v3.3.1 ### Xray-core version v26.6.1 ### How did you install 3x-ui? install.sh script ### Operating system Ubuntu 24 ### Which parts of the panel are affected? Frontend (UI / panel pages), Backend (API endpoints, login, settings) ### Browser (only if it is a UI bug) Chrome latest version ### 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:34:24 +07:00
Author
Owner

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

The subSortIndex field was introduced in v3.3.1 (released 2026-06-12, the same day as this report), so the behavior you are hitting is consistent with an early-adopter bug in a brand-new field.

What the code does (confirmed in source)

  • internal/database/model/model.go — Inbound.SubSortIndex carries gorm:"default:1", which means GORM's AutoMigrate adds the column with DEFAULT 1 when upgrading from an older install.
  • internal/database/db.go — on every startup, normalizeInboundSubSortIndex() runs UPDATE inbounds SET sub_sort_index = 1 WHERE sub_sort_index < 1 to clamp any zero values.
  • internal/web/service/inbound.go — UpdateInbound explicitly copies SubSortIndex from the incoming payload before calling tx.Save.
  • frontend/src/lib/xray/inbound-form-adapter.ts — rawInboundToFormValues reads row.subSortIndex and formValuesToWirePayload includes it in the POST body.

Everything in the read/write path looks structurally correct, so I cannot reproduce the reset from code inspection alone. A few targeted diagnostics would narrow it down quickly.

To help pinpoint the cause, please provide:

  1. Network tab confirmation — Open Chrome DevTools → Network tab. Reproduce the issue: open an affected inbound, change subSortIndex to something other than 1, and click Save. Find the POST /panel/api/inbounds/update/<id> request. In its Request Payload (or body), paste the value of the subSortIndex key. This confirms whether the browser is actually sending the new value.

  2. Response payload — On the same request, check the Response tab. Paste the subSortIndex field from the JSON response.

  3. Affected vs unaffected inbounds — Were the inbounds that do not retain the value created before upgrading to v3.3.1, or after? Were those that do retain it created fresh in v3.3.1?

  4. Console errors — Any JavaScript errors in the browser console around the time of saving?

One known edge case to be aware of

The startup normalization query — WHERE sub_sort_index < 1 — does not match NULL in SQL (because NULL < 1 evaluates to UNKNOWN, not TRUE). If any rows have a literal NULL value for the column (possible if the migration ran in an unusual environment), those rows would appear as subSortIndex: 0 in the API, and the form would display 1 via the Math.max(1, 0) clamp. This would not cause a persistent reset on its own, but it is worth ruling out. If you have SQLite access, running SELECT id, sub_sort_index FROM inbounds WHERE sub_sort_index IS NULL; on /etc/x-ui/x-ui.db would confirm or exclude this.

This reply was generated automatically; a maintainer may follow up.

<!-- gh-comment-id:4699775951 --> @github-actions[bot] commented on GitHub (Jun 13, 2026): The `subSortIndex` field was introduced in v3.3.1 (released 2026-06-12, the same day as this report), so the behavior you are hitting is consistent with an early-adopter bug in a brand-new field. **What the code does (confirmed in source)** - `internal/database/model/model.go` — `Inbound.SubSortIndex` carries `gorm:"default:1"`, which means GORM's `AutoMigrate` adds the column with `DEFAULT 1` when upgrading from an older install. - `internal/database/db.go` — on every startup, `normalizeInboundSubSortIndex()` runs `UPDATE inbounds SET sub_sort_index = 1 WHERE sub_sort_index < 1` to clamp any zero values. - `internal/web/service/inbound.go` — `UpdateInbound` explicitly copies `SubSortIndex` from the incoming payload before calling `tx.Save`. - `frontend/src/lib/xray/inbound-form-adapter.ts` — `rawInboundToFormValues` reads `row.subSortIndex` and `formValuesToWirePayload` includes it in the POST body. Everything in the read/write path looks structurally correct, so I cannot reproduce the reset from code inspection alone. A few targeted diagnostics would narrow it down quickly. **To help pinpoint the cause, please provide:** 1. **Network tab confirmation** — Open Chrome DevTools → Network tab. Reproduce the issue: open an affected inbound, change `subSortIndex` to something other than 1, and click Save. Find the `POST /panel/api/inbounds/update/<id>` request. In its Request Payload (or body), paste the value of the `subSortIndex` key. This confirms whether the browser is actually sending the new value. 2. **Response payload** — On the same request, check the Response tab. Paste the `subSortIndex` field from the JSON response. 3. **Affected vs unaffected inbounds** — Were the inbounds that do *not* retain the value created before upgrading to v3.3.1, or after? Were those that *do* retain it created fresh in v3.3.1? 4. **Console errors** — Any JavaScript errors in the browser console around the time of saving? **One known edge case to be aware of** The startup normalization query — `WHERE sub_sort_index < 1` — does not match `NULL` in SQL (because `NULL < 1` evaluates to `UNKNOWN`, not `TRUE`). If any rows have a literal `NULL` value for the column (possible if the migration ran in an unusual environment), those rows would appear as `subSortIndex: 0` in the API, and the form would display `1` via the `Math.max(1, 0)` clamp. This would not cause a persistent reset on its own, but it is worth ruling out. If you have SQLite access, running `SELECT id, sub_sort_index FROM inbounds WHERE sub_sort_index IS NULL;` on `/etc/x-ui/x-ui.db` would confirm or exclude this. *This reply was generated automatically; a maintainer may follow up.*
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#3711
No description provided.