[GH-ISSUE #5619] [Bug]: API: User remains disabled after renewing subscription on a node #3921

Closed
opened 2026-10-31 20:35:54 +07:00 by bsakaguchi · 2 comments
Owner

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

  • 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 @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 ```shell ``` ### 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 - [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:35:54 +07:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@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:

  1. client_traffics.enable = false
  2. client_records.enable = false (the clients table)
  3. The inbound settings JSON: "enable": false for the matching client entry (via markClientsDisabledInSettings)

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) and applyClientFieldByEmail (which backs the per-field setters such as ResetClientExpiryTimeByEmail) update only expiryTime, totalGB, and optionally flow in the inbound settings JSON and in client_traffics. Neither clears the "enable": false flag in any of the three locations above.

After a successful POST /panel/api/clients/bulkAdjust, the result is:

location expected actual
client_traffics.expiry_time new value new value ✓
client_traffics.enable true false ✗
client_records.enable true false ✗
inbound JSON "enable" true false ✗

For a node inbound, bulkAdjustInboundClients then calls rt.UpdateUser with a client payload built from entry.record.ToClient(). Because ClientRecord.Enable is false, the UpdateUser push also carries Enable: false to the remote node, reinforcing the disabled state there. On the next traffic poll the node snapshot reports cs.Enable = false, which — via ClientTrafficEnableMergeExpr (internal/database/dialect.go:27) — keeps client_traffics.enable at false on the master as well.

For comparison, the built-in auto-renew (autoRenewClients, internal/web/service/inbound_traffic.go:381) explicitly sets c["enable"] = true and traffic.Enable = true before saving. ResetTrafficByEmail (internal/web/service/client_traffic.go:30) explicitly checks \!rec.Enable and calls Update with Enable: 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:

POST /panel/api/clients/bulkEnable
{"emails": ["user@example.com"]}

Option 2 — reset traffic and re-enable in one call (also resets up/down counters to zero):

POST /panel/api/clients/resetTraffic/user@example.com

Option 3 — use the full update endpoint and include "enable": true in the body:

POST /panel/api/clients/update/user@example.com
{"enable": true, "expiryTime": <new_ms_timestamp>, ...}

Additional details needed

To help confirm exactly which endpoint is being called in your workflow, please share:

  1. The exact API endpoint and the JSON body you are sending for the renewal.
  2. Whether the API call targets the master panel or the node panel directly.
  3. Whether the client was disabled because of expiry, traffic exhaustion, or both.

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

<!-- gh-comment-id:4820275771 --> @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: 1. `client_traffics.enable = false` 2. `client_records.enable = false` (the `clients` table) 3. The inbound settings JSON: `"enable": false` for the matching client entry (via `markClientsDisabledInSettings`) 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`) and `applyClientFieldByEmail` (which backs the per-field setters such as `ResetClientExpiryTimeByEmail`) update only `expiryTime`, `totalGB`, and optionally `flow` in the inbound settings JSON and in `client_traffics`. Neither clears the `"enable": false` flag in any of the three locations above. After a successful `POST /panel/api/clients/bulkAdjust`, the result is: | location | expected | actual | |---|---|---| | `client_traffics.expiry_time` | new value | new value ✓ | | `client_traffics.enable` | `true` | `false` ✗ | | `client_records.enable` | `true` | `false` ✗ | | inbound JSON `"enable"` | `true` | `false` ✗ | For a node inbound, `bulkAdjustInboundClients` then calls `rt.UpdateUser` with a client payload built from `entry.record.ToClient()`. Because `ClientRecord.Enable` is `false`, the `UpdateUser` push also carries `Enable: false` to the remote node, reinforcing the disabled state there. On the next traffic poll the node snapshot reports `cs.Enable = false`, which — via `ClientTrafficEnableMergeExpr` (`internal/database/dialect.go:27`) — keeps `client_traffics.enable` at `false` on the master as well. For comparison, the built-in auto-renew (`autoRenewClients`, `internal/web/service/inbound_traffic.go:381`) explicitly sets `c["enable"] = true` and `traffic.Enable = true` before saving. `ResetTrafficByEmail` (`internal/web/service/client_traffic.go:30`) explicitly checks `\!rec.Enable` and calls `Update` with `Enable: 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: ``` POST /panel/api/clients/bulkEnable {"emails": ["user@example.com"]} ``` Option 2 — reset traffic and re-enable in one call (also resets `up`/`down` counters to zero): ``` POST /panel/api/clients/resetTraffic/user@example.com ``` Option 3 — use the full update endpoint and include `"enable": true` in the body: ``` POST /panel/api/clients/update/user@example.com {"enable": true, "expiryTime": <new_ms_timestamp>, ...} ``` **Additional details needed** To help confirm exactly which endpoint is being called in your workflow, please share: 1. The exact API endpoint and the JSON body you are sending for the renewal. 2. Whether the API call targets the master panel or the node panel directly. 3. Whether the client was disabled because of expiry, traffic exhaustion, or both. *This reply was generated automatically; a maintainer will follow up.*
Author
Owner

@MHSanaei commented on GitHub (Jun 29, 2026):

Fixed in 789e92cd.

bulkAdjust now 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 production depletedCond predicate and applied through the canonical BulkSetEnable, so all three stores (client_traffics, client_records, inbound JSON) and the node are updated. Manually-disabled or still-depleted clients are left disabled.

Update also now writes the clients.enable column 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.go and client_update_enable_test.go.

<!-- gh-comment-id:4832059384 --> @MHSanaei commented on GitHub (Jun 29, 2026): Fixed in 789e92cd. `bulkAdjust` now 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 production `depletedCond` predicate and applied through the canonical `BulkSetEnable`, so all three stores (client_traffics, client_records, inbound JSON) and the node are updated. Manually-disabled or still-depleted clients are left disabled. `Update` also now writes the `clients.enable` column 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.go` and `client_update_enable_test.go`.
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#3921
No description provided.