[PR #5988] [CLOSED] fix(clients): allow multiple clients to share a subId #6045

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

📋 Pull Request Information

Original PR: https://github.com/MHSanaei/3x-ui/pull/5988
Author: @oxsean
Created: 7/16/2026
Status: ❌ Closed

Base: main ← Head: fix/allow-shared-subid


📝 Commits (1)

  • e4293b4 fix(clients): allow multiple clients to share a subId

📊 Changes

4 files changed (+9 additions, -70 deletions)

View changed files

📝 internal/web/service/client_bulk.go (+0 -26)
📝 internal/web/service/client_crud.go (+0 -24)
📝 internal/web/service/client_portable.go (+0 -12)
📝 internal/web/service/client_update_rename_test.go (+9 -8)

📄 Description

Problem

Editing a client fails with Duplicate subId when its subscription ID matches another client's. In a multi-node setup, clients reconciled from different nodes are separate records with distinct emails and cannot be merged into one client, so a shared subId is the only way to aggregate them under a single subscription link.

Why the uniqueness check is wrong

Commit 88a36773 introduced per-client subId uniqueness on the grounds that the first-class client model aggregates via one client attached to many inbounds. That holds for top-down provisioning, but not for clients synced bottom-up from nodes. Meanwhile the subscription pipeline explicitly supports many records per subId: getInboundsBySubId joins across all clients with the subId, and indexStatsBySubId plucks every matching email (plural). The checks blocked a flow the sub server already serves.

Changes

  • Remove the subId collision checks in ClientService.Create, Update, BulkCreate and portable import (internal/web/service/client_crud.go, client_bulk.go, client_portable.go).
  • Email uniqueness is untouched, including the re-add identity checks that compare an existing email's subId.
  • Replace TestClientUpdateDuplicateSubIDDoesNotRenameEmail with TestClientUpdateAllowsSharedSubID, asserting an update to a shared subId succeeds and leaves the other client intact.

Testing

  • go test -shuffle=on -count=1 ./internal/web/service/ ./internal/sub/ — all pass (547 + sub package).
  • gofmt / go vet clean on changed files.

🔄 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/5988 **Author:** [@oxsean](https://github.com/oxsean) **Created:** 7/16/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/allow-shared-subid` --- ### 📝 Commits (1) - [`e4293b4`](https://github.com/MHSanaei/3x-ui/commit/e4293b455fd6a5e3542177c47ad9cdf59a3a3fe2) fix(clients): allow multiple clients to share a subId ### 📊 Changes **4 files changed** (+9 additions, -70 deletions) <details> <summary>View changed files</summary> 📝 `internal/web/service/client_bulk.go` (+0 -26) 📝 `internal/web/service/client_crud.go` (+0 -24) 📝 `internal/web/service/client_portable.go` (+0 -12) 📝 `internal/web/service/client_update_rename_test.go` (+9 -8) </details> ### 📄 Description ## Problem Editing a client fails with `Duplicate subId` when its subscription ID matches another client's. In a multi-node setup, clients reconciled from different nodes are separate records with distinct emails and cannot be merged into one client, so a shared subId is the only way to aggregate them under a single subscription link. ## Why the uniqueness check is wrong Commit 88a36773 introduced per-client subId uniqueness on the grounds that the first-class client model aggregates via one client attached to many inbounds. That holds for top-down provisioning, but not for clients synced bottom-up from nodes. Meanwhile the subscription pipeline explicitly supports many records per subId: `getInboundsBySubId` joins across all clients with the subId, and `indexStatsBySubId` plucks every matching email (plural). The checks blocked a flow the sub server already serves. ## Changes - Remove the subId collision checks in `ClientService.Create`, `Update`, `BulkCreate` and portable import (`internal/web/service/client_crud.go`, `client_bulk.go`, `client_portable.go`). - Email uniqueness is untouched, including the re-add identity checks that compare an existing email's subId. - Replace `TestClientUpdateDuplicateSubIDDoesNotRenameEmail` with `TestClientUpdateAllowsSharedSubID`, asserting an update to a shared subId succeeds and leaves the other client intact. ## Testing - `go test -shuffle=on -count=1 ./internal/web/service/ ./internal/sub/` — all pass (547 + sub package). - `gofmt` / `go vet` clean on changed files. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-02 04:05:58 +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#6045
No description provided.