[PR #6465] [MERGED] fix(inbounds): allow negative subSortIndex for subscription order #6288

Closed
opened 2026-11-02 04:07:42 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/MHSanaei/3x-ui/pull/6465
Author: @mrchatam
Created: 9/11/2026
Status: ✅ Merged
Merged: 9/12/2026
Merged by: @MHSanaei

Base: main ← Head: fix/allow-negative-sub-sort-index


📝 Commits (2)

  • 4609572 fix(inbounds): allow negative subSortIndex for subscription order
  • 8baedca fix(inbounds): gofumpt model.go and trim subSortIndex comments

📊 Changes

16 files changed (+116 additions, -52 deletions)

View changed files

📝 docs/public/openapi.json (+1 -2)
📝 frontend/public/openapi.json (+1 -2)
📝 frontend/src/generated/schemas.ts (+1 -2)
📝 frontend/src/generated/zod.ts (+1 -1)
📝 frontend/src/lib/xray/inbound-form-adapter.ts (+1 -1)
📝 frontend/src/pages/inbounds/form/InboundFormModal.tsx (+1 -1)
📝 frontend/src/pages/inbounds/list/InboundList.tsx (+1 -1)
📝 frontend/src/schemas/forms/inbound-form.ts (+1 -1)
📝 frontend/src/test/inbound-form-adapter.test.ts (+5 -8)
📝 internal/database/db.go (+3 -4)
📝 internal/database/model/model.go (+1 -1)
📝 internal/web/controller/inbound.go (+1 -1)
📝 internal/web/service/inbound_sub_sort_test.go (+51 -23)
📝 internal/web/service/inbound_subsort_test.go (+24 -0)
📝 internal/web/service/inbound_util.go (+3 -4)
➕ internal/web/service/inbound_util_test.go (+20 -0)

📄 Description

Summary

Fixes #5332

subSortIndex already drives subscription output order (ORDER BY sub_sort_index ASC), but every layer rejected values below 1, so primary inbounds could not sort first without bumping every other inbound.

This change keeps omitted/0 normalizing to 1 for backward compatibility, while preserving explicitly set negative indices end-to-end (model validation, API binding, service normalize, startup DB lift, form schema/UI, and generated OpenAPI).

Test plan

  • go test ./internal/web/service/ -run 'SubSort|NormalizeSubSort'
  • Frontend inbound-form-adapter vitest (including negative preservation)
  • Manually set inbound subSortIndex to -1 and confirm it sorts ahead of default 1 in subscription output

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/MHSanaei/3x-ui/pull/6465 **Author:** [@mrchatam](https://github.com/mrchatam) **Created:** 9/11/2026 **Status:** ✅ Merged **Merged:** 9/12/2026 **Merged by:** [@MHSanaei](https://github.com/MHSanaei) **Base:** `main` ← **Head:** `fix/allow-negative-sub-sort-index` --- ### 📝 Commits (2) - [`4609572`](https://github.com/MHSanaei/3x-ui/commit/460957211fbe35076820f4fee7cede136bbe4a39) fix(inbounds): allow negative subSortIndex for subscription order - [`8baedca`](https://github.com/MHSanaei/3x-ui/commit/8baedca7cd2292d851a749d42be0b615c35863cc) fix(inbounds): gofumpt model.go and trim subSortIndex comments ### 📊 Changes **16 files changed** (+116 additions, -52 deletions) <details> <summary>View changed files</summary> 📝 `docs/public/openapi.json` (+1 -2) 📝 `frontend/public/openapi.json` (+1 -2) 📝 `frontend/src/generated/schemas.ts` (+1 -2) 📝 `frontend/src/generated/zod.ts` (+1 -1) 📝 `frontend/src/lib/xray/inbound-form-adapter.ts` (+1 -1) 📝 `frontend/src/pages/inbounds/form/InboundFormModal.tsx` (+1 -1) 📝 `frontend/src/pages/inbounds/list/InboundList.tsx` (+1 -1) 📝 `frontend/src/schemas/forms/inbound-form.ts` (+1 -1) 📝 `frontend/src/test/inbound-form-adapter.test.ts` (+5 -8) 📝 `internal/database/db.go` (+3 -4) 📝 `internal/database/model/model.go` (+1 -1) 📝 `internal/web/controller/inbound.go` (+1 -1) 📝 `internal/web/service/inbound_sub_sort_test.go` (+51 -23) 📝 `internal/web/service/inbound_subsort_test.go` (+24 -0) 📝 `internal/web/service/inbound_util.go` (+3 -4) ➕ `internal/web/service/inbound_util_test.go` (+20 -0) </details> ### 📄 Description ## Summary Fixes #5332 `subSortIndex` already drives subscription output order (`ORDER BY sub_sort_index ASC`), but every layer rejected values below 1, so primary inbounds could not sort first without bumping every other inbound. This change keeps omitted/`0` normalizing to `1` for backward compatibility, while preserving explicitly set **negative** indices end-to-end (model validation, API binding, service normalize, startup DB lift, form schema/UI, and generated OpenAPI). ## Test plan - [x] `go test ./internal/web/service/ -run 'SubSort|NormalizeSubSort'` - [x] Frontend `inbound-form-adapter` vitest (including negative preservation) - [ ] Manually set inbound `subSortIndex` to `-1` and confirm it sorts ahead of default `1` in subscription output --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-02 04:07:42 +07:00
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#6288
No description provided.