[PR #6053] [MERGED] fix(clients): persist all editable fields for clients with no inbound #6067

Closed
opened 2026-11-02 04:06:08 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/MHSanaei/3x-ui/pull/6053
Author: @H-TTTTT
Created: 7/20/2026
Status: ✅ Merged
Merged: 7/21/2026
Merged by: @MHSanaei

Base: main ← Head: fix/client-fields-no-inbound


📝 Commits (1)

  • 49687e2 fix(clients): persist all editable fields for clients with no inbound

📊 Changes

3 files changed (+294 additions, -47 deletions)

View changed files

📝 internal/web/service/client_crud.go (+29 -0)
📝 internal/web/service/client_link.go (+60 -47)
➕ internal/web/service/client_update_no_inbound_test.go (+205 -0)

📄 Description

Summary

ClientService.Update only wrote most editable client fields to the clients table inside the per-inbound loop (UpdateInboundClient → SyncInbound). A client with no attached inbound (the external-links / remote-subscription client) therefore silently dropped subId, totalGB, expiryTime, limitIp, tgId, comment, reset, flow, security, and the credential fields on edit. Update still returned success, so the panel showed a saved toast while the row was untouched — matching the report exactly (stale subId after refresh, no error).

email/enable/group_name/ad_tag/reverse already had dedicated unconditional direct writes that covered the no-inbound case; the rest did not. This was a known failure shape: c4448f4e (closing #5870) added the no-inbound fallback for email only, and `TestUpdate_PersistsRecordEnable_NoInbound` covered enable only — both stayed scoped to a single field.

Changes

  • Extract SyncInbound's per-row field merge into a shared `applyClientRecordMerge(row, incoming)` — unconditional for scalar quota / lifecycle / subscription fields (so clearing them takes effect), preserve-when-empty for credentials and identifiers (so a partial update keeps the stored UUID / password / keys), earliest-known `CreatedAt`. `SyncInbound` is refactored to call it, so the two persistence paths cannot diverge.
  • Reuse the helper from `Update`: a new direct write runs only when the client has no attached inbound (`len(inboundIds) == 0`), covering all the previously-dropped columns. This is gated so it does not alter the inbound-attached path, where `flow` is per-inbound gated via `clientWithInboundFlow` and `SyncInbound` already persists every field.
  • `email`/`reverse`/`group_name`/`ad_tag`/`enable` keep their existing dedicated writes; the new write covers the remaining columns.

Verification

  • `go test ./internal/web/service/` — full package passes (existing `TestSyncInbound_*` guard the refactor; new `TestUpdate_PersistsFields_NoInbound` table-tests subId/totalGB/expiryTime/limitIp/tgId/comment/reset/flow/security/uuid, `TestUpdate_NoInbound_PreservesCredentialsWhenOmitted`, and `TestApplyClientRecordMerge_MirrorsSyncInboundRules`).
  • `gofmt` clean.

Fixes #5981


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/MHSanaei/3x-ui/pull/6053 **Author:** [@H-TTTTT](https://github.com/H-TTTTT) **Created:** 7/20/2026 **Status:** ✅ Merged **Merged:** 7/21/2026 **Merged by:** [@MHSanaei](https://github.com/MHSanaei) **Base:** `main` ← **Head:** `fix/client-fields-no-inbound` --- ### 📝 Commits (1) - [`49687e2`](https://github.com/MHSanaei/3x-ui/commit/49687e2b78eb862c5558d5e6b8fb872f64aea55f) fix(clients): persist all editable fields for clients with no inbound ### 📊 Changes **3 files changed** (+294 additions, -47 deletions) <details> <summary>View changed files</summary> 📝 `internal/web/service/client_crud.go` (+29 -0) 📝 `internal/web/service/client_link.go` (+60 -47) ➕ `internal/web/service/client_update_no_inbound_test.go` (+205 -0) </details> ### 📄 Description ## Summary `ClientService.Update` only wrote most editable client fields to the `clients` table **inside the per-inbound loop** (`UpdateInboundClient` → `SyncInbound`). A client with **no attached inbound** (the external-links / remote-subscription client) therefore silently dropped `subId`, `totalGB`, `expiryTime`, `limitIp`, `tgId`, `comment`, `reset`, `flow`, `security`, and the credential fields on edit. `Update` still returned success, so the panel showed a saved toast while the row was untouched — matching the report exactly (stale `subId` after refresh, no error). `email`/`enable`/`group_name`/`ad_tag`/`reverse` already had dedicated unconditional direct writes that covered the no-inbound case; the rest did not. This was a known failure shape: `c4448f4e` (closing #5870) added the no-inbound fallback for **email only**, and \`TestUpdate_PersistsRecordEnable_NoInbound\` covered **enable only** — both stayed scoped to a single field. ## Changes - **Extract** SyncInbound's per-row field merge into a shared \`applyClientRecordMerge(row, incoming)\` — unconditional for scalar quota / lifecycle / subscription fields (so clearing them takes effect), preserve-when-empty for credentials and identifiers (so a partial update keeps the stored UUID / password / keys), earliest-known \`CreatedAt\`. \`SyncInbound\` is refactored to call it, so the two persistence paths cannot diverge. - **Reuse** the helper from \`Update\`: a new direct write runs **only when the client has no attached inbound** (\`len(inboundIds) == 0\`), covering all the previously-dropped columns. This is gated so it does **not** alter the inbound-attached path, where \`flow\` is per-inbound gated via \`clientWithInboundFlow\` and \`SyncInbound\` already persists every field. - \`email\`/\`reverse\`/\`group_name\`/\`ad_tag\`/\`enable\` keep their existing dedicated writes; the new write covers the remaining columns. ## Verification - \`go test ./internal/web/service/\` — full package passes (existing \`TestSyncInbound_*\` guard the refactor; new \`TestUpdate_PersistsFields_NoInbound\` table-tests subId/totalGB/expiryTime/limitIp/tgId/comment/reset/flow/security/uuid, \`TestUpdate_NoInbound_PreservesCredentialsWhenOmitted\`, and \`TestApplyClientRecordMerge_MirrorsSyncInboundRules\`). - \`gofmt\` clean. Fixes #5981 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-02 04:06:08 +07:00
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#6067
No description provided.