mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[GH-ISSUE #5981] Client fields may not persist when no inbound is attached #4149
Labels
No labels
backlog
bug
clarification needed
documentation
duplicate
enhancement
github_actions
good first issue
invalid
javascript
New Feature
PR welcomed
pull-request
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
MHSanaei/3x-ui#4149
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @drownrat on GitHub (Jul 15, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/5981
Describe the bug
When editing a client that is not attached to any inbound, changing its Subscription ID (
subId) and saving does not persist the new value.The client in this case is used only to provide external links or remote subscriptions. If the same client is attached to at least one inbound, changing the Subscription ID works correctly.
I have only tested and confirmed this behavior for the Subscription ID. Other editable client fields may be affected by the same update path, so please audit all fields for clients without attached inbounds when fixing this issue.
Tested on v3.4.2. The relevant update path in the v3.5.0 source also appears to remain affected.
How to reproduce the problem
As a comparison, attach the client to at least one inbound and repeat the same steps. The Subscription ID is then saved correctly.
Expected behavior
Changes to the client record should be persisted regardless of whether the client is attached to an inbound.
Please also verify that all other editable client fields are correctly saved for clients without attached inbounds.
Actual behavior
The new Subscription ID is not persisted when the client has no attached inbound. The old value is shown again after refreshing or reopening the editor.
The same operation works correctly after attaching the client to an inbound.
Relevant logs
Screenshots
No response
3x-ui version
3.4.2
Xray-core version
26.6.27
How did you install 3x-ui?
install.sh script
Operating system
Debian 12
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
@github-actions[bot] commented on GitHub (Jul 15, 2026):
Root cause confirmed in
internal/web/service/client_crud.go, functionUpdate(backs both the REST API and the panel editor:frontend/src/hooks/useClients.ts:326→POST /panel/api/clients/update/{email}→internal/web/controller/client.go:56,167→UpdateByEmail→Update,client_crud.go:714,306).Title: Most editable client fields never reach the DB for a client with no attached inbound
Severity: High
Category: Correctness
Why this matters:
Updateonly writes the incoming client data to theclientstable two ways:for _, ibId := range inboundIds { ... }(client_crud.go:391-424), which callsUpdateInboundClient→SyncInbound(client_link.go:12).SyncInbound's per-row merge (client_link.go:69-117) is whereSubID,LimitIP,TotalGB,ExpiryTime,TgID,Comment,Reset,Flow, and the credential fields (UUID/Password/Auth/Secret/Security, WireGuard keys) actually get persisted — e.g.row.SubID = incoming.SubIDat line 102.UPDATEs that run after that loop regardless of inbound count:email(428-434),reverse(442-446),group_name(454-458),ad_tag(463-467),enable(469-473),updated_at(475-479).inboundIdscomes fromGetInboundIdsForRecord(client_lookup.go:114), which is an empty slice for a client with no attached inbound. When it's empty, path 1 never runs, and there is no fallback forsubIdor the other fields listed above —Updatestill returns success, so the panel shows a saved toast while the row is untouched. That matches the reported symptom exactly (stalesubIdafter refresh, no error).This is a known failure shape, not a new one: commit
c4448f4e("fix(clients): rename client record atomically with inbound settings", closing #5870) added the no-inbound direct-write fallback foremailspecifically ("Update now ... falls back to a direct rename solely for records with no attached inbound"). The equivalent gap forenableis covered by its own regression test,TestUpdate_PersistsRecordEnable_NoInbound(internal/web/service/client_update_enable_test.go:72, comment: "no-inbound persistence gap"). Both fixes were scoped to one field each and never generalized to the rest of the struct.This is a supported, intentional configuration, not a transient state: a client record can have zero rows in
client_inboundswhile still holding entries inclient_external_links(GetExternalLinksForRecord), which is the "external links / remote subscriptions" client described in the report.Answering the audit request: based on the code above, for a client with no attached inbound:
subId,totalGB(traffic limit),expiryTime,limitIp,tgId,comment,reset,flow, and credential fields (id/uuid,password,auth,secret,security, WireGuard keys) when changed.email,reverse,group,adTag,enable(each has the direct-write fallback described above).Recommendation: Generalize the pattern already used for
email/enable/group_name/ad_tag/reverse— add the same kind of unconditional direct write for the remainingClientRecordcolumns after the per-inbound loop, or restructureUpdateso one direct write of the full record always runs and the per-inboundSyncInboundcalls are only responsible for keeping each inbound's JSON in sync. A table-driven test parametrized over "0 inbounds" vs "≥1 inbound" per field, following the existingTestUpdate_PersistsRecordEnable_NoInboundpattern, would catch regressions of this shape.Workaround until fixed: attaching the client to any inbound before editing routes the update through path 1 and persists correctly, as noted in the report.
Example:
Confidence: High. Traced the full call path from frontend to DB write, cross-referenced against the prior
email-only fix (c4448f4e) and the existingenable-only regression test. Read-only investigation; not executed.@MHSanaei for a decision on the fix.
This reply was generated automatically. A maintainer may follow up.