[GH-ISSUE #6432] [Bug]: Attaching multiple clients to a VLESS inbound leaves flow empty (Disable XTLS flow off) #4354

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

Originally created by @AlexeyLCP on GitHub (Sep 7, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/6432

Describe the bug

With Disable XTLS flow unchecked on a flow-capable VLESS inbound (TCP + Reality/TLS), attaching clients should write flow: \"xtls-rprx-vision\" into each client in the inbound settings JSON and into share/subscription links (flow=xtls-rprx-vision).

What happens instead:

  • Attach VLESS to one existing client → flow is often set correctly.
  • Attach the same inbound to two (or more) existing clients (inbound Clients → attach existing / bulk attach) → every attached client is stored with flow: \"\".
  • Share links for those clients then omit flow=xtls-rprx-vision.
  • Opening the inbound JSON editor shows both clients with an empty flow string.

On some servers even attaching VLESS to a single existing client (created earlier without a VLESS inbound) never writes the flow line.

Disable XTLS flow is supposed to be the opt-out. When it is off, empty flow: \"\" should not be the default for clients on that inbound.

Related but not the same:

  • #5689 added the inbound DisableFlow opt-out (PR #5698). This report is the opposite: Vision is not applied when the checkbox is off.
  • #4792 / #5322 / #5232 were about multi-inbound / subscription flow and are closed. This reproduces on 3.7.0 with a single VLESS inbound and multiple clients.

Likely write-path gap (from current main):

  • ClientService.Attach copies EffectiveFlow onto the client before clientWithInboundFlow.
  • ClientService.BulkAttach uses rec.ToClient() as-is and never calls EffectiveFlow.
  • clientWithInboundFlow only strips flow when disableFlow is set or the inbound is not flow-capable. It never fills xtls-rprx-vision when the stored client flow is already empty (typical for clients that were created on a non-VLESS inbound first).

How to reproduce the problem

  1. Create two clients that are not yet on a VLESS inbound (or only on a non-flow protocol).
  2. Create a VLESS inbound: TCP + Reality (or TLS), Disable XTLS flow unchecked.
  3. From that inbound, attach both existing clients in one action (bulk attach).
  4. Open the inbound JSON editor (settings.clients) and copy each client share link.

Compare with attaching only one of those clients the same way.

Expected behavior

With Disable XTLS flow off, every client on that inbound should have:

\"flow\": \"xtls-rprx-vision\"

and the vless share/subscription link should contain flow=xtls-rprx-vision.

With Disable XTLS flow on, flow should stay empty.

Actual behavior

After attaching two clients, inbound JSON has flow: \"\" on both. Share links have no flow= parameter.

Attaching a single client to the same inbound often works.

Relevant logs

(none — panel save succeeds; Xray starts. The empty flow is in the inbound clients JSON.)

Screenshots

Inbound JSON after attaching two clients (Disable XTLS flow off):

\"clients\": [
  { \"email\": \"client-a\", \"flow\": \"\" },
  { \"email\": \"client-b\", \"flow\": \"\" }
]

Same inbound with one client attached (working case):

\"clients\": [
  { \"email\": \"client-a\", \"flow\": \"xtls-rprx-vision\" }
]

3x-ui version

3.7.0

Xray-core version

26.7.28

How did you install 3x-ui?

install.sh script

Operating system

Ubuntu 24.04 / Debian

Which parts of the panel are affected?

  • Frontend (UI / panel pages)
  • Backend (API endpoints, login, settings)
  • Xray config generation
  • Subscription (share links / Clash / JSON)

Browser (only if it is a UI bug)

No response

Is the panel behind a reverse proxy or CDN?

No — direct access

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 @AlexeyLCP on GitHub (Sep 7, 2026). Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/6432 ### Describe the bug With **Disable XTLS flow** unchecked on a flow-capable VLESS inbound (TCP + Reality/TLS), attaching clients should write `flow: \"xtls-rprx-vision\"` into each client in the inbound settings JSON and into share/subscription links (`flow=xtls-rprx-vision`). What happens instead: - Attach VLESS to **one** existing client → flow is often set correctly. - Attach the same inbound to **two (or more)** existing clients (inbound Clients → attach existing / bulk attach) → **every** attached client is stored with `flow: \"\"`. - Share links for those clients then omit `flow=xtls-rprx-vision`. - Opening the inbound JSON editor shows both clients with an empty flow string. On some servers even attaching VLESS to a **single** existing client (created earlier without a VLESS inbound) never writes the flow line. `Disable XTLS flow` is supposed to be the opt-out. When it is off, empty `flow: \"\"` should not be the default for clients on that inbound. Related but not the same: - #5689 added the inbound DisableFlow opt-out (PR #5698). This report is the opposite: Vision is **not** applied when the checkbox is off. - #4792 / #5322 / #5232 were about multi-inbound / subscription flow and are closed. This reproduces on 3.7.0 with a single VLESS inbound and multiple clients. Likely write-path gap (from current `main`): - `ClientService.Attach` copies `EffectiveFlow` onto the client before `clientWithInboundFlow`. - `ClientService.BulkAttach` uses `rec.ToClient()` as-is and never calls `EffectiveFlow`. - `clientWithInboundFlow` only **strips** flow when `disableFlow` is set or the inbound is not flow-capable. It never fills `xtls-rprx-vision` when the stored client flow is already empty (typical for clients that were created on a non-VLESS inbound first). ### How to reproduce the problem 1. Create two clients that are **not** yet on a VLESS inbound (or only on a non-flow protocol). 2. Create a VLESS inbound: TCP + Reality (or TLS), **Disable XTLS flow** unchecked. 3. From that inbound, attach **both** existing clients in one action (bulk attach). 4. Open the inbound JSON editor (`settings.clients`) and copy each client share link. Compare with attaching only **one** of those clients the same way. ### Expected behavior With Disable XTLS flow **off**, every client on that inbound should have: ```json \"flow\": \"xtls-rprx-vision\" ``` and the vless share/subscription link should contain `flow=xtls-rprx-vision`. With Disable XTLS flow **on**, `flow` should stay empty. ### Actual behavior After attaching two clients, inbound JSON has `flow: \"\"` on both. Share links have no `flow=` parameter. Attaching a single client to the same inbound often works. ### Relevant logs ```shell (none — panel save succeeds; Xray starts. The empty flow is in the inbound clients JSON.) ``` ### Screenshots Inbound JSON after attaching two clients (Disable XTLS flow off): ```json \"clients\": [ { \"email\": \"client-a\", \"flow\": \"\" }, { \"email\": \"client-b\", \"flow\": \"\" } ] ``` Same inbound with one client attached (working case): ```json \"clients\": [ { \"email\": \"client-a\", \"flow\": \"xtls-rprx-vision\" } ] ``` ### 3x-ui version 3.7.0 ### Xray-core version 26.7.28 ### How did you install 3x-ui? install.sh script ### Operating system Ubuntu 24.04 / Debian ### Which parts of the panel are affected? - Frontend (UI / panel pages) - Backend (API endpoints, login, settings) - Xray config generation - Subscription (share links / Clash / JSON) ### Browser (only if it is a UI bug) _No response_ ### Is the panel behind a reverse proxy or CDN? No — direct access ### 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).
Author
Owner

@github-actions[bot] commented on GitHub (Sep 7, 2026):

Your report splits into two halves: the behaviour you expected (empty flow should default to xtls-rprx-vision when Disable XTLS flow is off) is intended and will not change, but your read of the write path found a real defect — BulkAttach still seeds the client from the canonical clients.flow column, which is exactly the bug that was fixed for the single-client Attach path in #4834 and never applied to the bulk path. It is still present on the default branch.

1. The panel never auto-fills Vision — that part is by design

A client's flow is a per-client choice, not an inbound default. A new client's form starts empty:

// frontend/src/pages/clients/ClientFormModal.tsx:146
  flow: '',

and the restore path states the rule explicitly:

// internal/web/service/inbound_flow_restore.go:26-27
// is Vision. It never invents a flow for a client that has none anywhere, and it
// never overwrites an explicit non-empty flow.

It is also pinned by a test — TestEffectiveFlow_ClearedFlowStaysCleared (internal/web/service/client_flow_isolation_test.go:145), whose comment reads "User chose no flow: every inbound carries "".

Disable XTLS flow is the opt-out for propagating an existing Vision flow, not a switch that turns Vision on. Its own help string says so:

"disableFlowHelp": "Opt this inbound out of automatic xtls-rprx-vision injection, ..."

(internal/web/translation/en-US.json:668)

So your reproduction steps as written — clients that were only ever on a non-flow protocol, i.e. clients with no Vision flow anywhere — produce "flow": "" correctly, on both the single and the bulk path.

2. The real bug: bulk attach drops a Vision flow the client does have

Attach derives the flow from the per-inbound flow_override:

// internal/web/service/client_crud.go:965-970
	clientWire := existing.ToClient()
	flow, ffErr := s.EffectiveFlow(nil, id)
	...
	clientWire.Flow = flow

BulkAttach does not — it takes the record as-is:

// internal/web/service/client_bulk.go:102
			client := *rec.ToClient()

and ToClient() copies the canonical column (internal/database/model/model.go:1181, Flow: r.Flow). That column is unreliable, which is why EffectiveFlow exists (internal/web/service/client_lookup.go:27-33, issue #4792): every sync writes it unconditionally —

// internal/web/service/client_link.go:38
	row.Flow = incoming.Flow

— so as soon as a non-flow inbound (WS/gRPC/Hysteria/Trojan/SS…) syncs last, clients.flow becomes "" while the Reality inbound's flow_override still holds Vision. Bulk-attaching that client then writes "flow": "", and clientWithInboundFlow cannot save it because it only ever strips (internal/web/service/client_crud.go:434-437) — your third bullet is correct, though that stripping-only behaviour is itself intended.

The trigger is the code path, not the number of clients. The inbound page's attach existing clients modal always posts to the bulk endpoint, one client or ten:

// frontend/src/pages/inbounds/clients/AttachExistingClientsModal.tsx:153-157
        '/panel/api/clients/bulkAttach',
        { emails: selectedEmails, inboundIds: [target.id] },

Adding an inbound from the Clients page client editor instead goes to /panel/api/clients/{email}/attach (frontend/src/pages/clients/ClientsPage.tsx:969 → internal/web/controller/client.go:271 → Attach), which uses EffectiveFlow and keeps Vision. That asymmetry is what you saw as "sometimes it works".

Workarounds today

  1. Open the target inbound and save it unchanged — UpdateInbound runs restoreVisionFlowForEligibleInbound (internal/web/service/inbound.go:1603-1606) and re-adds Vision to clients whose intended flow is Vision.
  2. Or set it explicitly for many clients at once: Clients page → bulk adjust, flow xtls-rprx-vision (/panel/api/clients/bulkAdjust; honoured on flow-eligible inbounds, internal/web/service/client_bulk.go:654-688). This also works for clients that never had a flow.

Which case are you hitting?

Open the client in the Clients-page editor before attaching. The flow shown there is EffectiveFlow-derived (internal/web/controller/client.go:121-125). If it shows xtls-rprx-vision there but the inbound JSON has "" after bulk attach, that is the confirmed bug; if it is empty there too, the client has no Vision anywhere and workaround 2 is the answer.

I also retitled the issue for the maintainer — from "[Bug]: Attaching multiple clients to a VLESS inbound leaves flow empty (Disable XTLS flow off)" — because the client count is not the trigger.


Verdict: Confirmed bug
Severity: Medium
Confidence: High
Root cause: ClientService.BulkAttach, internal/web/service/client_bulk.go:102 — client := *rec.ToClient() seeds the wire client from the denormalized clients.flow column instead of EffectiveFlow. Triggered whenever a bulk-attached client's canonical column has been zeroed by a non-flow inbound's sync (internal/web/service/client_link.go:38) while a sibling inbound's flow_override still holds Vision. BulkAttach landed in 1a096d72 (2026-05-28, feat(inbounds): bulk-attach & assign-group client actions); b08fc0c9 (2026-06-02, fix(clients): keep reverse tag clearable and preserve flow on attach, issue #4834) fixed the identical read in Attach and did not touch the bulk path.
Already fixed: Still present on the default branch (a5e68f41); v3.7.0 is the latest release, so the reporter is at the tip.
Duplicate of: None. Related: #4834 (same defect, fixed for Attach only), #5689 / PR #5698 (the DisableFlow opt-out this report contrasts with).
Evidence: internal/web/service/client_bulk.go:102,108; internal/web/service/client_crud.go:965-970 (Attach uses EffectiveFlow) and :434-437 (clientWithInboundFlow strips only); internal/database/model/model.go:1181; internal/web/service/client_link.go:38; internal/web/service/client_lookup.go:27-33; intended-behaviour side: internal/web/service/inbound_flow_restore.go:26-27, TestEffectiveFlow_ClearedFlowStaysCleared (client_flow_isolation_test.go:145-189), TestAttach_PreservesVisionFlowWhenCanonicalColumnZeroed (client_flow_isolation_test.go:191-265), frontend/src/pages/clients/ClientFormModal.tsx:146. No test covers flow on the bulk path — internal/web/service/bulk_clients_test.go contains no flow assertion at all.
Not determined: Whether the reporter's own servers hit the confirmed defect or the by-design empty-flow case; their steps describe clients with no Vision flow anywhere, which is the intended case. The client-editor flow value before attaching (see above) settles it.

Suggested fix: In BulkAttach, resolve the flow the same way Attach does — EffectiveFlow/EffectiveFlowsByEmails for the record set — before clientWithInboundFlow gates it per inbound. A regression test belongs next to TestAttach_PreservesVisionFlowWhenCanonicalColumnZeroed, driving BulkAttach with the canonical clients.flow zeroed.

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

<!-- gh-comment-id:5573800002 --> @github-actions[bot] commented on GitHub (Sep 7, 2026): Your report splits into two halves: the behaviour you *expected* (empty flow should default to `xtls-rprx-vision` when **Disable XTLS flow** is off) is intended and will not change, but your read of the write path found a **real defect** — `BulkAttach` still seeds the client from the canonical `clients.flow` column, which is exactly the bug that was fixed for the single-client `Attach` path in #4834 and never applied to the bulk path. It is still present on the default branch. ## 1. The panel never auto-fills Vision — that part is by design A client's flow is a per-client choice, not an inbound default. A new client's form starts empty: ```ts // frontend/src/pages/clients/ClientFormModal.tsx:146 flow: '', ``` and the restore path states the rule explicitly: ```go // internal/web/service/inbound_flow_restore.go:26-27 // is Vision. It never invents a flow for a client that has none anywhere, and it // never overwrites an explicit non-empty flow. ``` It is also pinned by a test — `TestEffectiveFlow_ClearedFlowStaysCleared` (`internal/web/service/client_flow_isolation_test.go:145`), whose comment reads *"User chose no flow: every inbound carries ``"``"*. **Disable XTLS flow** is the opt-out for *propagating* an existing Vision flow, not a switch that turns Vision on. Its own help string says so: ```json "disableFlowHelp": "Opt this inbound out of automatic xtls-rprx-vision injection, ..." ``` (`internal/web/translation/en-US.json:668`) So your reproduction steps as written — clients that were only ever on a non-flow protocol, i.e. clients with no Vision flow anywhere — produce `"flow": ""` **correctly**, on both the single and the bulk path. ## 2. The real bug: bulk attach drops a Vision flow the client does have `Attach` derives the flow from the per-inbound `flow_override`: ```go // internal/web/service/client_crud.go:965-970 clientWire := existing.ToClient() flow, ffErr := s.EffectiveFlow(nil, id) ... clientWire.Flow = flow ``` `BulkAttach` does not — it takes the record as-is: ```go // internal/web/service/client_bulk.go:102 client := *rec.ToClient() ``` and `ToClient()` copies the canonical column (`internal/database/model/model.go:1181`, `Flow: r.Flow`). That column is unreliable, which is why `EffectiveFlow` exists (`internal/web/service/client_lookup.go:27-33`, issue #4792): every sync writes it unconditionally — ```go // internal/web/service/client_link.go:38 row.Flow = incoming.Flow ``` — so as soon as a non-flow inbound (WS/gRPC/Hysteria/Trojan/SS…) syncs last, `clients.flow` becomes `""` while the Reality inbound's `flow_override` still holds Vision. Bulk-attaching that client then writes `"flow": ""`, and `clientWithInboundFlow` cannot save it because it only ever *strips* (`internal/web/service/client_crud.go:434-437`) — your third bullet is correct, though that stripping-only behaviour is itself intended. **The trigger is the code path, not the number of clients.** The inbound page's *attach existing clients* modal always posts to the bulk endpoint, one client or ten: ```ts // frontend/src/pages/inbounds/clients/AttachExistingClientsModal.tsx:153-157 '/panel/api/clients/bulkAttach', { emails: selectedEmails, inboundIds: [target.id] }, ``` Adding an inbound from the **Clients page** client editor instead goes to `/panel/api/clients/{email}/attach` (`frontend/src/pages/clients/ClientsPage.tsx:969` → `internal/web/controller/client.go:271` → `Attach`), which uses `EffectiveFlow` and keeps Vision. That asymmetry is what you saw as "sometimes it works". ### Workarounds today 1. Open the target inbound and save it unchanged — `UpdateInbound` runs `restoreVisionFlowForEligibleInbound` (`internal/web/service/inbound.go:1603-1606`) and re-adds Vision to clients whose intended flow is Vision. 2. Or set it explicitly for many clients at once: Clients page → bulk adjust, flow `xtls-rprx-vision` (`/panel/api/clients/bulkAdjust`; honoured on flow-eligible inbounds, `internal/web/service/client_bulk.go:654-688`). This also works for clients that never had a flow. ### Which case are you hitting? Open the client in the Clients-page editor **before** attaching. The flow shown there is `EffectiveFlow`-derived (`internal/web/controller/client.go:121-125`). If it shows `xtls-rprx-vision` there but the inbound JSON has `""` after bulk attach, that is the confirmed bug; if it is empty there too, the client has no Vision anywhere and workaround 2 is the answer. I also retitled the issue for the maintainer — from *"[Bug]: Attaching multiple clients to a VLESS inbound leaves flow empty (Disable XTLS flow off)"* — because the client count is not the trigger. --- Verdict: Confirmed bug Severity: Medium Confidence: High Root cause: `ClientService.BulkAttach`, `internal/web/service/client_bulk.go:102` — `client := *rec.ToClient()` seeds the wire client from the denormalized `clients.flow` column instead of `EffectiveFlow`. Triggered whenever a bulk-attached client's canonical column has been zeroed by a non-flow inbound's sync (`internal/web/service/client_link.go:38`) while a sibling inbound's `flow_override` still holds Vision. `BulkAttach` landed in `1a096d72` (2026-05-28, *feat(inbounds): bulk-attach & assign-group client actions*); `b08fc0c9` (2026-06-02, *fix(clients): keep reverse tag clearable and preserve flow on attach*, issue #4834) fixed the identical read in `Attach` and did not touch the bulk path. Already fixed: Still present on the default branch (`a5e68f41`); v3.7.0 is the latest release, so the reporter is at the tip. Duplicate of: None. Related: #4834 (same defect, fixed for `Attach` only), #5689 / PR #5698 (the `DisableFlow` opt-out this report contrasts with). Evidence: `internal/web/service/client_bulk.go:102,108`; `internal/web/service/client_crud.go:965-970` (Attach uses `EffectiveFlow`) and `:434-437` (`clientWithInboundFlow` strips only); `internal/database/model/model.go:1181`; `internal/web/service/client_link.go:38`; `internal/web/service/client_lookup.go:27-33`; intended-behaviour side: `internal/web/service/inbound_flow_restore.go:26-27`, `TestEffectiveFlow_ClearedFlowStaysCleared` (`client_flow_isolation_test.go:145-189`), `TestAttach_PreservesVisionFlowWhenCanonicalColumnZeroed` (`client_flow_isolation_test.go:191-265`), `frontend/src/pages/clients/ClientFormModal.tsx:146`. No test covers flow on the bulk path — `internal/web/service/bulk_clients_test.go` contains no flow assertion at all. Not determined: Whether the reporter's own servers hit the confirmed defect or the by-design empty-flow case; their steps describe clients with no Vision flow anywhere, which is the intended case. The client-editor flow value before attaching (see above) settles it. Suggested fix: In `BulkAttach`, resolve the flow the same way `Attach` does — `EffectiveFlow`/`EffectiveFlowsByEmails` for the record set — before `clientWithInboundFlow` gates it per inbound. A regression test belongs next to `TestAttach_PreservesVisionFlowWhenCanonicalColumnZeroed`, driving `BulkAttach` with the canonical `clients.flow` zeroed. *This reply was generated automatically; a maintainer may follow up.* <!-- claude-issue:analyst -->
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#4354
No description provided.