[GH-ISSUE #6098] [Bug]: [Regression 3.5.0] Client remark suffix is applied only to first inbound in multi-inbound subscription #4215

Closed
opened 2026-10-31 20:38:01 +07:00 by bsakaguchi · 6 comments
Owner

Originally created by @x-ander-t on GitHub (Jul 25, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/6098

Describe the bug

Regression after update to 3.5.0

When generating a subscription containing multiple inbounds for one client, the client remark suffix is appended only to the first inbound.

Example client:

iPhone-AT

Expected:

vless-tls-cascade-iPhone-AT
vless-reality-cascade-iPhone-AT
hysteria2-cascade-iPhone-AT
vless-tls-direct-iPhone-AT
vless-reality-direct-iPhone-AT
hysteria2-direct-iPhone-AT

Actual:

vless-tls-cascade-iPhone-AT

vless-reality-cascade
hysteria2-cascade
vless-tls-direct
vless-reality-direct
hysteria2-direct

The issue occurs in both:

  • Happ
  • INCY

Environment

3x-ui:
3.5.0

Xray-core:
26.7.11

Impact

When multiple users have similar inbound names, profiles become indistinguishable.

This makes multi-client subscription management difficult.

Expected behavior

The client remark should be applied to every generated subscription item.

How to reproduce the problem

  1. Create one client.
  2. Attach this client to multiple inbounds.
  3. Create subscription.
  4. Import subscription into Happ or INCY.
  5. Check generated profile names.

Expected behavior

No response

Actual behavior

No response

Relevant logs


Screenshots

No response

3x-ui version

3.5.0

Xray-core version

26.7.11

How did you install 3x-ui?

install.sh script

Operating system

Ubuntu 24.04

Which parts of the panel are affected?

No response

Browser (only if it is a UI bug)

No response

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 @x-ander-t on GitHub (Jul 25, 2026). Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/6098 ### Describe the bug ### Regression after update to 3.5.0 When generating a subscription containing multiple inbounds for one client, the client remark suffix is appended only to the first inbound. Example client: iPhone-AT Expected: vless-tls-cascade-iPhone-AT vless-reality-cascade-iPhone-AT hysteria2-cascade-iPhone-AT vless-tls-direct-iPhone-AT vless-reality-direct-iPhone-AT hysteria2-direct-iPhone-AT Actual: vless-tls-cascade-iPhone-AT vless-reality-cascade hysteria2-cascade vless-tls-direct vless-reality-direct hysteria2-direct The issue occurs in both: - Happ - INCY ### Environment 3x-ui: 3.5.0 Xray-core: 26.7.11 ### Impact When multiple users have similar inbound names, profiles become indistinguishable. This makes multi-client subscription management difficult. ### Expected behavior The client remark should be applied to every generated subscription item. ### How to reproduce the problem 1. Create one client. 2. Attach this client to multiple inbounds. 3. Create subscription. 4. Import subscription into Happ or INCY. 5. Check generated profile names. ### Expected behavior _No response_ ### Actual behavior _No response_ ### Relevant logs ```shell ``` ### Screenshots _No response_ ### 3x-ui version 3.5.0 ### Xray-core version 26.7.11 ### How did you install 3x-ui? install.sh script ### Operating system Ubuntu 24.04 ### Which parts of the panel are affected? _No response_ ### Browser (only if it is a UI bug) _No response_ ### 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:38:01 +07:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@embyinfuse-debug commented on GitHub (Jul 25, 2026):

生成的配制 不能用呀!

<!-- gh-comment-id:5077691361 --> @embyinfuse-debug commented on GitHub (Jul 25, 2026): 生成的配制 不能用呀!
Author
Owner

@x-ander-t commented on GitHub (Jul 25, 2026):

Only happens when template is not empty. For an empty template works properly. But for example, this template {{INBOUND}}-{{EMAIL}} for “email=iPhone-AT-happy” gives the attached screenshot.

Image
<!-- gh-comment-id:5078222140 --> @x-ander-t commented on GitHub (Jul 25, 2026): Only happens when template is not empty. For an empty template works properly. But for example, this template {{INBOUND}}-{{EMAIL}} for “email=iPhone-AT-happy” gives the attached screenshot. <img width="1320" height="1035" alt="Image" src="https://github.com/user-attachments/assets/b03249f4-281e-4112-9545-40b23d4a7b0d" />
Author
Owner

@MHSanaei commented on GitHub (Jul 25, 2026):

@claude

<!-- gh-comment-id:5080309155 --> @MHSanaei commented on GitHub (Jul 25, 2026): @claude
Author
Owner

@github-actions[bot] commented on GitHub (Jul 25, 2026):

Claude finished @MHSanaei's task in 3m 34s —— View job


This is not specific to the first inbound — it is the first link generated for that client email in the subscription response. Everything after it loses the identity tokens.

Root cause

internal/sub/remark_vars.go:488-491 puts EMAIL/USERNAME in the same bucket as the usage tokens:

var firstLinkOnlyBodyTokens = mergeTokenSets(usageInfoTokens, map[string]bool{
	"EMAIL":    true,
	"USERNAME": true,
})

effectiveTemplate (internal/sub/remark_vars.go:557-567) applies that set to every link after the first, tracked per email in s.usageShown:

if s.usageShown[email] {
	return filterRemarkTemplate(translated, firstLinkOnlyBodyTokens)
}
s.usageShown[email] = true

usageShown is per request (internal/sub/service.go:98), and one SubService renders every link of the subscription, so whichever inbound sorts first for that client — Order("sub_sort_index ASC").Order("id ASC") in getInboundsBySubId, internal/sub/service.go:470 — keeps the email and the rest do not. That is exactly the screenshot: vless-tls-cascade-iPhone-AT-happ, then bare names.

It only affects the subscription body (subscriptionBody == true: raw /sub, /json, /clash). The panel link/QR display path uses displayRemoveTokens (internal/sub/remark_vars.go:482), which does not contain EMAIL, so the email still shows there — hence the inconsistency you see between the panel and the imported profiles.

Your observation about the empty template is also explained: with no template, genHostRemark (internal/sub/remark_vars.go:606-611) takes the fallbackRemark(inbound.Remark, hostRemark, client.Email) branch (internal/sub/service.go:1883), which appends the email unconditionally to every link.

Where it came from

Commit 876d55f2 "fix(sub): show {{EMAIL}} on first sub-body link only" (2026-06-27), requested in #5659. git tag --contains 876d55f2 reports v3.4.2 and v3.5.0, so the change is present since v3.4.2; upgrading from v3.4.1 or older to v3.5.0 surfaces it as a v3.5.0 regression. Since the shipped default template is {{INBOUND}}-{{EMAIL}}|📊{{TRAFFIC_LEFT}}|⏳{{DAYS_LEFT}}D (internal/web/service/setting.go:39), every default install with a client on several inbounds is affected. The same report came in as #6029.

Fix

Restore the identity tokens on every body link, leaving the usage tokens first-link-only as before. In internal/sub/remark_vars.go, delete the firstLinkOnlyBodyTokens block (lines 484-491, comment included) so the file reads:

var displayRemoveTokens = mergeTokenSets(usageInfoTokens, connectionTokens)

func mergeTokenSets(sets ...map[string]bool) map[string]bool {

and in effectiveTemplate (line 563):

	if s.usageShown[email] {
		return filterRemarkTemplate(translated, usageInfoTokens)
	}

Two tests pin the current behavior and must be inverted.

internal/sub/remark_vars_test.go:627-655 — replace TestEmailOnFirstLinkOnly with:

func TestEmailOnEveryLink(t *testing.T) {
	s := &SubService{
		remarkTemplate:   "{{INBOUND}} {{EMAIL}}|📊{{TRAFFIC_LEFT}}",
		subscriptionBody: true,
		usageShown:       map[string]bool{},
	}
	inbound := &model.Inbound{
		Remark: "DE",
		ClientStats: []xray.ClientTraffic{{
			Email:  "alice@x",
			Enable: true,
			Total:  100 * gb,
		}},
	}
	client := model.Client{Email: "alice@x"}
	first := s.genTemplatedRemark(inbound, client, "", "ws")
	second := s.genTemplatedRemark(inbound, client, "", "ws")
	for _, remark := range []string{first, second} {
		if !strings.Contains(remark, "alice@x") {
			t.Fatalf("every body link must carry the client email: %q", remark)
		}
		if !strings.Contains(remark, "DE") {
			t.Fatalf("every body link must carry the inbound name: %q", remark)
		}
	}
	if strings.Contains(second, "📊") {
		t.Fatalf("repeat body link must still drop the usage block: %q", second)
	}
}

internal/sub/remark_vars_test.go:387-391 — in TestIdentityTokenBodyVsDisplay, the body half asserts the opposite of the desired behavior:

	body := &SubService{remarkTemplate: tmpl, subscriptionBody: true, usageShown: map[string]bool{}}
	_ = body.genTemplatedRemark(inbound, client, "", "ws")
	if second := body.genTemplatedRemark(inbound, client, "", "ws"); !strings.Contains(second, "john@x") {
		t.Fatalf("repeat body link %q must keep the identity token", second)
	}

No other test references the identity tokens across multiple links (export_all_links_test.go generates a single link), and docs/content/docs/en/config/share-links.mdx documents the first-link-only rule for usage tokens only, so no doc change is needed.

One decision for you

PR #5935 is open and takes the other route: a subShowIdentityOnAllLinks setting defaulting to false. With that default, a fresh install still produces exactly what is reported here, and #5659 (the request behind 876d55f2) is satisfied by an opt-in either way. If you prefer the setting over the plain revert, defaulting it to true covers both this report and #5659.

I could not execute go test ./internal/sub/ in this run (command not permitted), so the fix above is derived from reading the code path rather than from a local test run. This workflow only investigates and replies; it does not commit or open pull requests.

<!-- gh-comment-id:5080309938 --> @github-actions[bot] commented on GitHub (Jul 25, 2026): **Claude finished @MHSanaei's task in 3m 34s** —— [View job](https://github.com/MHSanaei/3x-ui/actions/runs/30172244615) --- ### Confirmed: `{{EMAIL}}` is stripped from every link after a client's first one This is not specific to the first *inbound* — it is the first *link generated for that client email* in the subscription response. Everything after it loses the identity tokens. ### Root cause `internal/sub/remark_vars.go:488-491` puts `EMAIL`/`USERNAME` in the same bucket as the usage tokens: ```go var firstLinkOnlyBodyTokens = mergeTokenSets(usageInfoTokens, map[string]bool{ "EMAIL": true, "USERNAME": true, }) ``` `effectiveTemplate` (`internal/sub/remark_vars.go:557-567`) applies that set to every link after the first, tracked per email in `s.usageShown`: ```go if s.usageShown[email] { return filterRemarkTemplate(translated, firstLinkOnlyBodyTokens) } s.usageShown[email] = true ``` `usageShown` is per request (`internal/sub/service.go:98`), and one `SubService` renders every link of the subscription, so whichever inbound sorts first for that client — `Order("sub_sort_index ASC").Order("id ASC")` in `getInboundsBySubId`, `internal/sub/service.go:470` — keeps the email and the rest do not. That is exactly the screenshot: `vless-tls-cascade-iPhone-AT-happ`, then bare names. It only affects the subscription body (`subscriptionBody == true`: raw `/sub`, `/json`, `/clash`). The panel link/QR display path uses `displayRemoveTokens` (`internal/sub/remark_vars.go:482`), which does not contain `EMAIL`, so the email still shows there — hence the inconsistency you see between the panel and the imported profiles. Your observation about the empty template is also explained: with no template, `genHostRemark` (`internal/sub/remark_vars.go:606-611`) takes the `fallbackRemark(inbound.Remark, hostRemark, client.Email)` branch (`internal/sub/service.go:1883`), which appends the email unconditionally to every link. ### Where it came from Commit `876d55f2` "fix(sub): show {{EMAIL}} on first sub-body link only" (2026-06-27), requested in #5659. `git tag --contains 876d55f2` reports `v3.4.2` and `v3.5.0`, so the change is present since v3.4.2; upgrading from v3.4.1 or older to v3.5.0 surfaces it as a v3.5.0 regression. Since the shipped default template is `{{INBOUND}}-{{EMAIL}}|📊{{TRAFFIC_LEFT}}|⏳{{DAYS_LEFT}}D` (`internal/web/service/setting.go:39`), every default install with a client on several inbounds is affected. The same report came in as #6029. ### Fix Restore the identity tokens on every body link, leaving the usage tokens first-link-only as before. In `internal/sub/remark_vars.go`, delete the `firstLinkOnlyBodyTokens` block (lines 484-491, comment included) so the file reads: ```go var displayRemoveTokens = mergeTokenSets(usageInfoTokens, connectionTokens) func mergeTokenSets(sets ...map[string]bool) map[string]bool { ``` and in `effectiveTemplate` (line 563): ```go if s.usageShown[email] { return filterRemarkTemplate(translated, usageInfoTokens) } ``` Two tests pin the current behavior and must be inverted. `internal/sub/remark_vars_test.go:627-655` — replace `TestEmailOnFirstLinkOnly` with: ```go func TestEmailOnEveryLink(t *testing.T) { s := &SubService{ remarkTemplate: "{{INBOUND}} {{EMAIL}}|📊{{TRAFFIC_LEFT}}", subscriptionBody: true, usageShown: map[string]bool{}, } inbound := &model.Inbound{ Remark: "DE", ClientStats: []xray.ClientTraffic{{ Email: "alice@x", Enable: true, Total: 100 * gb, }}, } client := model.Client{Email: "alice@x"} first := s.genTemplatedRemark(inbound, client, "", "ws") second := s.genTemplatedRemark(inbound, client, "", "ws") for _, remark := range []string{first, second} { if !strings.Contains(remark, "alice@x") { t.Fatalf("every body link must carry the client email: %q", remark) } if !strings.Contains(remark, "DE") { t.Fatalf("every body link must carry the inbound name: %q", remark) } } if strings.Contains(second, "📊") { t.Fatalf("repeat body link must still drop the usage block: %q", second) } } ``` `internal/sub/remark_vars_test.go:387-391` — in `TestIdentityTokenBodyVsDisplay`, the body half asserts the opposite of the desired behavior: ```go body := &SubService{remarkTemplate: tmpl, subscriptionBody: true, usageShown: map[string]bool{}} _ = body.genTemplatedRemark(inbound, client, "", "ws") if second := body.genTemplatedRemark(inbound, client, "", "ws"); !strings.Contains(second, "john@x") { t.Fatalf("repeat body link %q must keep the identity token", second) } ``` No other test references the identity tokens across multiple links (`export_all_links_test.go` generates a single link), and `docs/content/docs/en/config/share-links.mdx` documents the first-link-only rule for usage tokens only, so no doc change is needed. ### One decision for you PR #5935 is open and takes the other route: a `subShowIdentityOnAllLinks` setting defaulting to `false`. With that default, a fresh install still produces exactly what is reported here, and #5659 (the request behind `876d55f2`) is satisfied by an opt-in either way. If you prefer the setting over the plain revert, defaulting it to `true` covers both this report and #5659. I could not execute `go test ./internal/sub/` in this run (command not permitted), so the fix above is derived from reading the code path rather than from a local test run. This workflow only investigates and replies; it does not commit or open pull requests.
Author
Owner

@MHSanaei commented on GitHub (Jul 27, 2026):

Fixed in c004c18d.

You were right that it is a regression, and your follow-up about the empty template was the clue that identified it. It is not per-inbound but per-client: 876d55f2 put EMAIL/USERNAME into the same first-link-only bucket as the usage tokens, so whichever inbound sorts first for that client keeps the identity and every later link is stripped. With no template configured a different code path runs, which appends the email unconditionally — hence "works properly for an empty template".

The two token groups are not alike. The usage block repeats the same numbers on every link, so showing it once is reasonable. The identity is what tells one imported profile from another, which is the whole point of putting it in the name. {{EMAIL}} and {{USERNAME}} are now kept on every subscription-body link; the usage tokens stay first-link-only, unchanged.

This also covers #6029 and #5659, which asked for the same thing.

Since the shipped default template is {{INBOUND}}-{{EMAIL}}|📊{{TRAFFIC_LEFT}}|⏳{{DAYS_LEFT}}D, every default install with a client on several inbounds was affected. It will be in the next release; clients need to re-fetch the subscription to pick up the new names.

<!-- gh-comment-id:5091393771 --> @MHSanaei commented on GitHub (Jul 27, 2026): Fixed in c004c18d. You were right that it is a regression, and your follow-up about the empty template was the clue that identified it. It is not per-inbound but per-client: `876d55f2` put `EMAIL`/`USERNAME` into the same first-link-only bucket as the usage tokens, so whichever inbound sorts first for that client keeps the identity and every later link is stripped. With no template configured a different code path runs, which appends the email unconditionally — hence "works properly for an empty template". The two token groups are not alike. The usage block repeats the same numbers on every link, so showing it once is reasonable. The identity is what tells one imported profile from another, which is the whole point of putting it in the name. `{{EMAIL}}` and `{{USERNAME}}` are now kept on every subscription-body link; the usage tokens stay first-link-only, unchanged. This also covers #6029 and #5659, which asked for the same thing. Since the shipped default template is `{{INBOUND}}-{{EMAIL}}|📊{{TRAFFIC_LEFT}}|⏳{{DAYS_LEFT}}D`, every default install with a client on several inbounds was affected. It will be in the next release; clients need to re-fetch the subscription to pick up the new names.
Author
Owner

@MHSanaei commented on GitHub (Jul 27, 2026):

Correction: I was wrong to treat this as a regression, and I have reverted the change in fd17255f.

Showing {{EMAIL}} / {{USERNAME}} on the first subscription-body link only is deliberate, not an oversight in 876d55f2. All links in a single-client subscription carry the same email, so it is treated like the traffic block — shown once, to keep remarks short for operators with many inbounds per subscription. My earlier comment read the intent backwards. Sorry for the noise, and for the churn to anyone who saw the panel behave differently in the meantime.

That leaves the underlying request, which is legitimate: some operators do want the identity on every link so profiles stay distinguishable in the client app when several clients share inbound names. The route for that is a setting rather than flipping the default for everyone, and #5935 is exactly that — it adds subShowIdentityOnAllLinks. If this matters to your deployment, that PR is the place to say so.

Until it lands, a template that puts something client-specific outside the identity tokens gives you distinguishable names on every link. For example {{INBOUND}}-{{SUB_ID}} or {{INBOUND}}-{{SHORT_ID}}, since SUB_ID and SHORT_ID are not in the first-link-only set.

Closing as intended behaviour. cc @x-ander-t @embyinfuse-debug

<!-- gh-comment-id:5094758824 --> @MHSanaei commented on GitHub (Jul 27, 2026): Correction: I was wrong to treat this as a regression, and I have reverted the change in fd17255f. Showing `{{EMAIL}}` / `{{USERNAME}}` on the first subscription-body link only is deliberate, not an oversight in `876d55f2`. All links in a single-client subscription carry the same email, so it is treated like the traffic block — shown once, to keep remarks short for operators with many inbounds per subscription. My earlier comment read the intent backwards. Sorry for the noise, and for the churn to anyone who saw the panel behave differently in the meantime. That leaves the underlying request, which is legitimate: some operators do want the identity on every link so profiles stay distinguishable in the client app when several clients share inbound names. The route for that is a setting rather than flipping the default for everyone, and **#5935** is exactly that — it adds `subShowIdentityOnAllLinks`. If this matters to your deployment, that PR is the place to say so. Until it lands, a template that puts something client-specific outside the identity tokens gives you distinguishable names on every link. For example `{{INBOUND}}-{{SUB_ID}}` or `{{INBOUND}}-{{SHORT_ID}}`, since `SUB_ID` and `SHORT_ID` are not in the first-link-only set. Closing as intended behaviour. cc @x-ander-t @embyinfuse-debug
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#4215
No description provided.