mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[GH-ISSUE #5619] [Bug]: API: User remains disabled after renewing subscription on a node #3921
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#3921
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 @sina0101 on GitHub (Jun 27, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/5619
Describe the bug
When using the 3x-ui API with a server configured as a Node, renewing a user's subscription via the API sometimes behaves incorrectly.
The renewal request is successful, and the user's expiration time is updated correctly. However, the user's status remains disabled, making the account unusable until it is manually enabled from the panel
How to reproduce the problem
Bug Description
When using the 3x-ui API with a server configured as a Node, renewing a user's subscription via the API sometimes behaves incorrectly.
The renewal request is successful, and the user's expiration time is updated correctly. However, the user's status remains disabled, making the account unusable until it is manually enabled from the panel.
Expected behavior
After a successful renewal through the API:
The expiration time should be updated.
If the renewal is successful, the user should remain enabled (or be automatically re-enabled if appropriate).
Actual behavior
The API returns success.
The user's expiration date is extended.
The user stays disabled.
The account cannot be used until it is manually enabled in the panel.
Relevant logs
Screenshots
No response
3x-ui version
3.4.1
Xray-core version
26.6.22
How did you install 3x-ui?
install.sh script
Operating system
Ubuntu 24
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?
No response
Before submitting
@github-actions[bot] commented on GitHub (Jun 27, 2026):
This is a confirmed bug in the renewal path of the API when a client has previously been auto-disabled by the expiry/traffic enforcement loop.
What the disable loop does
disableInvalidClients(internal/web/service/inbound_disable.go) stores the disabled state in three places simultaneously:client_traffics.enable = falseclient_records.enable = false(theclientstable)"enable": falsefor the matching client entry (viamarkClientsDisabledInSettings)For node inbounds the same state is pushed to the remote node via
disableRemoteClients→rt.UpdateInbound.What the renewal path does (or does not do)
BulkAdjust(internal/web/service/client_bulk.go,bulkAdjustInboundClients) andapplyClientFieldByEmail(which backs the per-field setters such asResetClientExpiryTimeByEmail) update onlyexpiryTime,totalGB, and optionallyflowin the inbound settings JSON and inclient_traffics. Neither clears the"enable": falseflag in any of the three locations above.After a successful
POST /panel/api/clients/bulkAdjust, the result is:client_traffics.expiry_timeclient_traffics.enabletruefalse✗client_records.enabletruefalse✗"enable"truefalse✗For a node inbound,
bulkAdjustInboundClientsthen callsrt.UpdateUserwith a client payload built fromentry.record.ToClient(). BecauseClientRecord.Enableisfalse, theUpdateUserpush also carriesEnable: falseto the remote node, reinforcing the disabled state there. On the next traffic poll the node snapshot reportscs.Enable = false, which — viaClientTrafficEnableMergeExpr(internal/database/dialect.go:27) — keepsclient_traffics.enableatfalseon the master as well.For comparison, the built-in auto-renew (
autoRenewClients,internal/web/service/inbound_traffic.go:381) explicitly setsc["enable"] = trueandtraffic.Enable = truebefore saving.ResetTrafficByEmail(internal/web/service/client_traffic.go:30) explicitly checks\!rec.Enableand callsUpdatewithEnable: true. The renewal APIs do not apply the same logic.Workaround
After extending the expiry via the API, re-enable the client explicitly with one of the following:
Option 1 — re-enable without resetting traffic:
Option 2 — reset traffic and re-enable in one call (also resets
up/downcounters to zero):Option 3 — use the full update endpoint and include
"enable": truein the body:Additional details needed
To help confirm exactly which endpoint is being called in your workflow, please share:
This reply was generated automatically; a maintainer will follow up.
@MHSanaei commented on GitHub (Jun 29, 2026):
Fixed in
789e92cd.bulkAdjustnow re-enables a client on renewal only when it was disabled because it was depleted (expired or over quota) and the adjustment lifts it back within limits — computed as a set-difference of the productiondepletedCondpredicate and applied through the canonicalBulkSetEnable, so all three stores (client_traffics, client_records, inbound JSON) and the node are updated. Manually-disabled or still-depleted clients are left disabled.Updatealso now writes theclients.enablecolumn explicitly, so re-enabling sticks for inbound-less clients and stops feeding a stale record into node pushes.Covered by 14 new tests in
client_bulk_reenable_test.goandclient_update_enable_test.go.