[GH-ISSUE #5998] [Bug]: "Remark Template" is only applied to the first inbound in subscription #4154

Closed
opened 2026-10-31 20:37:34 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @vwelsonf on GitHub (Jul 16, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/5998

Describe the bug

Describe the bug

The "Remark Template" setting in the panel settings/subscription section only applies to the very first inbound link generated in the subscription. All subsequent inbound links in the same subscription ignore this template and fall back to the default format or ignore the setting entirely.

According to the description, this template should replace the remark model for each subscription link.

Actual result

  • First inbound: Correctly uses the custom remark template (e.g., "Germany").
  • Second and subsequent inbounds: Do not use the template (they use default names or standard formats).

Expected behavior

The "Remark Template" format should be applied to all inbound links within the subscription, not just the first one.

Panel Version

v3.5.0

How to reproduce the problem

  1. Go to Panel Settings -> Subscription Settings.
  2. In the "Remark Template" field, set a custom template (e.g., {{INBOUND}}).
  3. Create a client/subscription that contains multiple inbounds (e.g., 3 different protocols or ports).
  4. Export or open the subscription link.
  5. Observe the remarks (names) of the imported configurations.

Expected behavior

No response

Actual behavior

No response

Relevant logs


Screenshots

No response

3x-ui version

3.5.0

Xray-core version

No response

How did you install 3x-ui?

install.sh script

Operating system

Ubuntu 22.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 @vwelsonf on GitHub (Jul 16, 2026). Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/5998 ### Describe the bug ### Describe the bug The "Remark Template" setting in the panel settings/subscription section only applies to the very first inbound link generated in the subscription. All subsequent inbound links in the same subscription ignore this template and fall back to the default format or ignore the setting entirely. According to the description, this template should replace the remark model for *each* subscription link. ### Actual result * **First inbound:** Correctly uses the custom remark template (e.g., "Germany"). * **Second and subsequent inbounds:** Do not use the template (they use default names or standard formats). ### Expected behavior The "Remark Template" format should be applied to **all** inbound links within the subscription, not just the first one. ### Panel Version v3.5.0 ### How to reproduce the problem 1. Go to Panel Settings -> Subscription Settings. 2. In the "Remark Template" field, set a custom template (e.g., `{{INBOUND}}`). 3. Create a client/subscription that contains multiple inbounds (e.g., 3 different protocols or ports). 4. Export or open the subscription link. 5. Observe the remarks (names) of the imported configurations. ### Expected behavior _No response_ ### Actual behavior _No response_ ### Relevant logs ```shell ``` ### Screenshots _No response_ ### 3x-ui version 3.5.0 ### Xray-core version _No response_ ### How did you install 3x-ui? install.sh script ### Operating system Ubuntu 22.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:37:34 +07:00
Author
Owner

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

Confirmed the underlying mechanism in the source, with one open question about your exact template that I need answered to be certain it's the whole story.

Title: Remark Template's usage/expiry/identity tokens are dropped after a client's first link in a multi-inbound subscription, contradicting the setting's own description

Severity: Medium

Category: Correctness / Documentation

Why this matters: In internal/sub/remark_vars.go, every body link goes through genTemplatedRemark (line 581) -> effectiveTemplate(email) (line 557):

func (s *SubService) effectiveTemplate(email string) string {
    translated := translateUISingleBrackets(s.remarkTemplate)
    ...
    if s.usageShown[email] {
        return filterRemarkTemplate(translated, firstLinkOnlyBodyTokens)
    }
    s.usageShown[email] = true
    return translated
}

The first link generated for a given client email in the request gets the full template. Every later link for that same email is passed through firstLinkOnlyBodyTokens (defined lines 468-491), which strips {{EMAIL}}/{{USERNAME}} plus every usage/expiry/status token (TRAFFIC_LEFT, TRAFFIC_TOTAL, DAYS_LEFT, STATUS, TIME_LEFT, etc.). {{INBOUND}}, {{HOST}}, {{PROTOCOL}}, {{TRANSPORT}} and {{SECURITY}} are not in that set and render on every link (see TestConnectionTokensOnEveryBodyLink and the final assertion of TestEmailOnFirstLinkOnly in internal/sub/remark_vars_test.go).

This is intentional — added by commit 876d55f ("show {{EMAIL}} on first sub-body link only", shipped in v3.4.2 onward, so it's present in your v3.5.0) on top of an earlier traffic-only restriction. It is not an edge case for multi-inbound subscriptions: Client.Email is globally unique at the DB level (ClientRecord.Email, internal/database/model/model.go:828), and the panel's only way to put one client on several inbounds is attaching that same client (clients row, client_inbounds join table, internal/web/service/client_link.go:210-236) to each inbound — so every client with more than one inbound in its subscription hits this path.

The problem: this silently contradicts what the panel promises. The setting's own description (internal/web/translation/en-US.json:1260) reads "When set, this replaces the remark model for every subscription link," and the docs (docs/content/docs/en/config/share-links.mdx) only document the separate display/QR-view stripping, not this per-email body stripping. Two other reports already ran into this same mechanism: #5618 (closed without a code change) and #5659 (open, asking specifically to revert or make the {{EMAIL}} half optional).

Recommendation: Either (a) correct the setting description and docs to state that identity/usage tokens render on a client's first subscription-body link only while structural tokens ({{INBOUND}}, {{HOST}}, {{PROTOCOL}}, {{TRANSPORT}}, {{SECURITY}}) render on every link, or (b) make it configurable — a toggle that bypasses firstLinkOnlyBodyTokens (internal/sub/remark_vars.go:488) for operators who want the full template repeated on every link, as already requested in #5659. No code change will be made unless a maintainer requests it.

Confidence: High on the mechanism and that it's the most likely explanation, given the panel's data model makes shared emails across a multi-inbound subscription the normal case, not an exception.

One thing the source alone can't settle: your reproduction uses {{INBOUND}} as the example template, and {{INBOUND}} by itself is never stripped by this mechanism — with a template of literally just {{INBOUND}}, every link should already show that link's own inbound name. If your actual configured template also includes {{EMAIL}}, {{TRAFFIC_LEFT}}, {{DAYS_LEFT}}, {{STATUS}}, or similar (as the built-in default does), the behavior above is what you're seeing — later links keep the inbound name but drop those other parts. To close the loop, could you provide:

  1. The exact string in Settings -> Subscription -> Remark Template (copy-paste, not paraphrased).
  2. Confirmation that the 3 inbounds belong to the same client (added via "Attach to inbounds"/bulk-attach, sharing one email) rather than 3 separate clients with different emails.

@MHSanaei for a decision on whether to fix the docs, add a toggle, or both.

This reply was generated automatically; a maintainer may follow up.

<!-- gh-comment-id:4990932091 --> @github-actions[bot] commented on GitHub (Jul 16, 2026): Confirmed the underlying mechanism in the source, with one open question about your exact template that I need answered to be certain it's the whole story. **Title:** Remark Template's usage/expiry/identity tokens are dropped after a client's first link in a multi-inbound subscription, contradicting the setting's own description **Severity:** Medium **Category:** Correctness / Documentation **Why this matters:** In `internal/sub/remark_vars.go`, every body link goes through `genTemplatedRemark` (line 581) -> `effectiveTemplate(email)` (line 557): ```go func (s *SubService) effectiveTemplate(email string) string { translated := translateUISingleBrackets(s.remarkTemplate) ... if s.usageShown[email] { return filterRemarkTemplate(translated, firstLinkOnlyBodyTokens) } s.usageShown[email] = true return translated } ``` The first link generated for a given client `email` in the request gets the full template. Every later link for that *same* email is passed through `firstLinkOnlyBodyTokens` (defined lines 468-491), which strips `{{EMAIL}}`/`{{USERNAME}}` plus every usage/expiry/status token (`TRAFFIC_LEFT`, `TRAFFIC_TOTAL`, `DAYS_LEFT`, `STATUS`, `TIME_LEFT`, etc.). `{{INBOUND}}`, `{{HOST}}`, `{{PROTOCOL}}`, `{{TRANSPORT}}` and `{{SECURITY}}` are **not** in that set and render on every link (see `TestConnectionTokensOnEveryBodyLink` and the final assertion of `TestEmailOnFirstLinkOnly` in `internal/sub/remark_vars_test.go`). This is intentional — added by commit `876d55f` ("show `{{EMAIL}}` on first sub-body link only", shipped in v3.4.2 onward, so it's present in your v3.5.0) on top of an earlier traffic-only restriction. It is not an edge case for multi-inbound subscriptions: `Client.Email` is globally unique at the DB level (`ClientRecord.Email`, `internal/database/model/model.go:828`), and the panel's only way to put one client on several inbounds is attaching that *same* client (`clients` row, `client_inbounds` join table, `internal/web/service/client_link.go:210-236`) to each inbound — so every client with more than one inbound in its subscription hits this path. The problem: this silently contradicts what the panel promises. The setting's own description (`internal/web/translation/en-US.json:1260`) reads "When set, this replaces the remark model for **every** subscription link," and the docs (`docs/content/docs/en/config/share-links.mdx`) only document the separate display/QR-view stripping, not this per-email body stripping. Two other reports already ran into this same mechanism: #5618 (closed without a code change) and #5659 (open, asking specifically to revert or make the `{{EMAIL}}` half optional). **Recommendation:** Either (a) correct the setting description and docs to state that identity/usage tokens render on a client's first subscription-body link only while structural tokens (`{{INBOUND}}`, `{{HOST}}`, `{{PROTOCOL}}`, `{{TRANSPORT}}`, `{{SECURITY}}`) render on every link, or (b) make it configurable — a toggle that bypasses `firstLinkOnlyBodyTokens` (`internal/sub/remark_vars.go:488`) for operators who want the full template repeated on every link, as already requested in #5659. No code change will be made unless a maintainer requests it. **Confidence:** High on the mechanism and that it's the most likely explanation, given the panel's data model makes shared emails across a multi-inbound subscription the normal case, not an exception. One thing the source alone can't settle: your reproduction uses `{{INBOUND}}` as the example template, and `{{INBOUND}}` by itself is never stripped by this mechanism — with a template of literally just `{{INBOUND}}`, every link should already show that link's own inbound name. If your actual configured template also includes `{{EMAIL}}`, `{{TRAFFIC_LEFT}}`, `{{DAYS_LEFT}}`, `{{STATUS}}`, or similar (as the built-in default does), the behavior above is what you're seeing — later links keep the inbound name but drop those other parts. To close the loop, could you provide: 1. The exact string in Settings -> Subscription -> Remark Template (copy-paste, not paraphrased). 2. Confirmation that the 3 inbounds belong to the *same* client (added via "Attach to inbounds"/bulk-attach, sharing one email) rather than 3 separate clients with different emails. @MHSanaei for a decision on whether to fix the docs, add a toggle, or both. *This reply was generated automatically; a maintainer may follow up.*
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#4154
No description provided.