[PR #4979] [CLOSED] fix(clients): restore shared subId compatibility #5751

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

📋 Pull Request Information

Original PR: https://github.com/MHSanaei/3x-ui/pull/4979
Author: @ergolyam
Created: 6/5/2026
Status: ❌ Closed

Base: main ← Head: sub-id-fix


📝 Commits (1)

  • 5ae23e1 fix(clients): restore shared subId compatibility

📊 Changes

2 files changed (+121 additions, -49 deletions)

View changed files

📝 web/service/client.go (+0 -49)
➕ web/service/client_shared_subid_test.go (+121 -0)

📄 Description

Summary

Restore compatibility for shared client subscription IDs by allowing multiple clients to use the same subId again. Email uniqueness is still enforced; subId is treated as a subscription grouping key.

Why

Some existing deployments use one subscription ID to expose several client configs/transports under the same subscription URL. This used to work, and the subscription generator still supports it by returning every enabled client matching the requested subId.

The recent service-layer uniqueness checks blocked new or edited clients with an existing subId, causing subId already in use / Duplicate subId errors even though the database schema does not enforce sub_id uniqueness.

Refs #4759, #4927, #4953, #4785.

Type of change

  • Bug fix
  • New feature
  • Refactoring (no behavior change)
  • Documentation
  • Tests only
  • Build / CI / tooling
  • Other

Areas affected

  • Frontend (UI / panel pages)
  • Backend (API endpoints, login, settings)
  • Xray config generation
  • Subscription (share links / Clash / JSON)
  • Statistics / traffic counters
  • Database / migrations
  • Install / upgrade script
  • Docker image
  • Multi-node (sub-nodes)
  • Telegram bot

How was this tested?

Added regression tests covering shared subId behavior for:

  • single client create
  • client update
  • bulk client create

Commands run:

env CGO_ENABLED=1 go test ./web/service -run SharedSubID
env CGO_ENABLED=1 go test ./web/service
env CGO_ENABLED=1 go test ./web/service ./sub ./web/controller
git diff --check

I also tried:

env CGO_ENABLED=1 go test ./...

That command is blocked in this checkout because web/web.go embeds web/dist, which is not present:

web/web.go:44:12: pattern all:dist: no matching files found

Screenshots / recordings

N/A.

Breaking changes

None. This restores the previous shared-subscription behavior and does not require a migration or API payload changes.

Checklist

  • I tested the change locally and confirmed the described behavior.
  • I added or updated tests for the new behavior (when applicable).
  • go build ./... and the test suite pass locally.
  • For frontend changes: npm run lint, npm run typecheck, and npm run build pass.
  • I updated the Wiki / README / API docs if user-facing behavior changed.
  • My commits follow the project's existing message style.
  • I have no unrelated changes mixed into this PR.

🔄 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/4979 **Author:** [@ergolyam](https://github.com/ergolyam) **Created:** 6/5/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `sub-id-fix` --- ### 📝 Commits (1) - [`5ae23e1`](https://github.com/MHSanaei/3x-ui/commit/5ae23e13a4835e115d2ce6a405919cd4914b5ea1) fix(clients): restore shared subId compatibility ### 📊 Changes **2 files changed** (+121 additions, -49 deletions) <details> <summary>View changed files</summary> 📝 `web/service/client.go` (+0 -49) ➕ `web/service/client_shared_subid_test.go` (+121 -0) </details> ### 📄 Description ## Summary Restore compatibility for shared client subscription IDs by allowing multiple clients to use the same `subId` again. Email uniqueness is still enforced; `subId` is treated as a subscription grouping key. ## Why Some existing deployments use one subscription ID to expose several client configs/transports under the same subscription URL. This used to work, and the subscription generator still supports it by returning every enabled client matching the requested `subId`. The recent service-layer uniqueness checks blocked new or edited clients with an existing `subId`, causing `subId already in use` / `Duplicate subId` errors even though the database schema does not enforce `sub_id` uniqueness. Refs #4759, #4927, #4953, #4785. ## Type of change - [x] Bug fix - [ ] New feature - [ ] Refactoring (no behavior change) - [ ] Documentation - [ ] Tests only - [ ] Build / CI / tooling - [ ] Other ## Areas affected - [ ] Frontend (UI / panel pages) - [x] Backend (API endpoints, login, settings) - [ ] Xray config generation - [x] Subscription (share links / Clash / JSON) - [ ] Statistics / traffic counters - [ ] Database / migrations - [ ] Install / upgrade script - [ ] Docker image - [ ] Multi-node (sub-nodes) - [ ] Telegram bot ## How was this tested? Added regression tests covering shared `subId` behavior for: - single client create - client update - bulk client create Commands run: ```sh env CGO_ENABLED=1 go test ./web/service -run SharedSubID env CGO_ENABLED=1 go test ./web/service env CGO_ENABLED=1 go test ./web/service ./sub ./web/controller git diff --check ``` I also tried: ```sh env CGO_ENABLED=1 go test ./... ``` That command is blocked in this checkout because `web/web.go` embeds `web/dist`, which is not present: ```text web/web.go:44:12: pattern all:dist: no matching files found ``` ## Screenshots / recordings N/A. ## Breaking changes None. This restores the previous shared-subscription behavior and does not require a migration or API payload changes. ## Checklist - [x] I tested the change locally and confirmed the described behavior. - [x] I added or updated tests for the new behavior (when applicable). - [ ] `go build ./...` and the test suite pass locally. - [ ] For frontend changes: `npm run lint`, `npm run typecheck`, and `npm run build` pass. - [x] I updated the Wiki / README / API docs if user-facing behavior changed. - [x] My commits follow the project's existing message style. - [x] I have no unrelated changes mixed into this PR. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-02 04:03:49 +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#5751
No description provided.