[PR #6345] [MERGED] fix(outbounds): preserve stable subscription tags #6227

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

📋 Pull Request Information

Original PR: https://github.com/MHSanaei/3x-ui/pull/6345
Author: @dawNotPoi
Created: 8/28/2026
Status: ✅ Merged
Merged: 9/2/2026
Merged by: @MHSanaei

Base: main ← Head: fix/6341-stable-subscription-tags


📝 Commits (1)

  • c309cd3 fix(outbounds): preserve stable subscription tags

📊 Changes

2 files changed (+54 additions, -3 deletions)

View changed files

📝 internal/web/service/outbound_subscription.go (+11 -2)
📝 internal/web/service/outbound_subscription_test.go (+43 -1)

📄 Description

Summary

  • Reserve historical tags for identities that are still present before assigning tags to new links.
  • Prevent positional fallback, fresh allocation, and collision suffixes from taking those reserved tags.
  • Add regression coverage for inserted links and fresh/suffix collisions.

Why

A newly inserted subscription link could reuse the positional tag of an existing server before that server was processed. The existing server was then assigned a suffixed tag, and the swapped identity-to-tag mapping was persisted across refreshes.

This could silently make an exact routing or balancer tag point to a different physical server.

Closes #6341

Existing subscriptions whose mapping was already corrupted cannot be repaired unambiguously and may still need to be removed and added again once.

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?

Regression coverage confirms:

  • a new link inserted before an existing identity cannot take its stable tag;
  • a fresh tag cannot collide with a stable tag;
  • suffix allocation skips multiple reserved tags;
  • a positional tag remains reusable after its former identity disappears.

Commands run:

  • go test -count=100 -run '^TestAssignStableTags$' ./internal/web/service
  • go test -race -shuffle=on -count=1 ./internal/web/service
  • go test ./internal/web/service -count=1
  • make lint
  • make verify
  • git diff --check

The inserted-link regression test was also confirmed to fail against the parent commit and pass with this change.

Screenshots / recordings

N/A — backend-only behavior change.

Breaking changes

None.

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/6345 **Author:** [@dawNotPoi](https://github.com/dawNotPoi) **Created:** 8/28/2026 **Status:** ✅ Merged **Merged:** 9/2/2026 **Merged by:** [@MHSanaei](https://github.com/MHSanaei) **Base:** `main` ← **Head:** `fix/6341-stable-subscription-tags` --- ### 📝 Commits (1) - [`c309cd3`](https://github.com/MHSanaei/3x-ui/commit/c309cd334b10fc36b27380a9a8cf62a6ac7de093) fix(outbounds): preserve stable subscription tags ### 📊 Changes **2 files changed** (+54 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `internal/web/service/outbound_subscription.go` (+11 -2) 📝 `internal/web/service/outbound_subscription_test.go` (+43 -1) </details> ### 📄 Description ## Summary - Reserve historical tags for identities that are still present before assigning tags to new links. - Prevent positional fallback, fresh allocation, and collision suffixes from taking those reserved tags. - Add regression coverage for inserted links and fresh/suffix collisions. ## Why A newly inserted subscription link could reuse the positional tag of an existing server before that server was processed. The existing server was then assigned a suffixed tag, and the swapped identity-to-tag mapping was persisted across refreshes. This could silently make an exact routing or balancer tag point to a different physical server. Closes #6341 Existing subscriptions whose mapping was already corrupted cannot be repaired unambiguously and may still need to be removed and added again once. ## 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) - [x] 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? Regression coverage confirms: - a new link inserted before an existing identity cannot take its stable tag; - a fresh tag cannot collide with a stable tag; - suffix allocation skips multiple reserved tags; - a positional tag remains reusable after its former identity disappears. Commands run: - `go test -count=100 -run '^TestAssignStableTags$' ./internal/web/service` - `go test -race -shuffle=on -count=1 ./internal/web/service` - `go test ./internal/web/service -count=1` - `make lint` - `make verify` - `git diff --check` The inserted-link regression test was also confirmed to fail against the parent commit and pass with this change. ## Screenshots / recordings N/A — backend-only behavior change. ## Breaking changes None. ## Checklist - [x] I tested the change locally and confirmed the described behavior. - [x] I added or updated tests for the new behavior (when applicable). - [x] `go build ./...` and the test suite pass locally. - [x] 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:07:15 +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#6227
No description provided.