[GH-ISSUE #6009] [Bug]: Shadowsocks client renewal fails with Client.tgId JSON error #4160

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

Originally created by @mori-1997-mori2276-cmd on GitHub (Jul 17, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/6009

Describe the bug

Hello. I found a bug in the latest x-ui version. When editing or renewing a Shadowsocks client, the panel returns this error:
json: cannot unmarshal string into Go struct field Client.tgId of type int64
This issue only happens with Shadowsocks clients. VLESS works normally. If I downgrade to x-ui v3.4.2, the problem disappears. Could you please check if this is a regression in the latest release? Thank you.

How to reproduce the problem

Install the latest x-ui version.
Create a Shadowsocks client (or use an existing one).
Open the client and change any value (or renew/extend the expiry time).
Click Save.
The panel returns the following error:

Expected behavior

No response

Actual behavior

No response

Relevant logs


Screenshots

Image

3x-ui version

3.5.0

Xray-core version

26.7.11

How did you install 3x-ui?

install.sh script

Operating system

  1.   26
    

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

  • 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 @mori-1997-mori2276-cmd on GitHub (Jul 17, 2026). Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/6009 ### Describe the bug Hello. I found a bug in the latest x-ui version. When editing or renewing a Shadowsocks client, the panel returns this error: json: cannot unmarshal string into Go struct field Client.tgId of type int64 This issue only happens with Shadowsocks clients. VLESS works normally. If I downgrade to x-ui v3.4.2, the problem disappears. Could you please check if this is a regression in the latest release? Thank you. ### How to reproduce the problem Install the latest x-ui version. Create a Shadowsocks client (or use an existing one). Open the client and change any value (or renew/extend the expiry time). Click Save. The panel returns the following error: ### Expected behavior _No response_ ### Actual behavior _No response_ ### Relevant logs ```shell ``` ### Screenshots <img width="4320" height="1172" alt="Image" src="https://github.com/user-attachments/assets/db810ac5-1f08-4559-bf77-f50ab29b0f63" /> ### 3x-ui version 3.5.0 ### Xray-core version 26.7.11 ### How did you install 3x-ui? install.sh script ### Operating system 24. 26 ### 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 - [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:37:36 +07:00
Author
Owner

@github-actions[bot] commented on GitHub (Jul 17, 2026):

This is the same underlying bug as #5934: identical error (json: cannot unmarshal string into Go struct field Client.tgId of type int64) on the same version (3.5.0). Closing as a duplicate to keep the discussion in one place — please follow #5934 for the full root-cause write-up and an unblocking workaround.

Root cause: model.Client.TgID (internal/database/model/model.go:817) is a strict int64. If the affected inbound's stored settings.clients[] contains a client with a non-numeric legacy tgId (e.g. an old "" value), ParseInboundSettingsClients (internal/web/service/inbound_settings_clients.go:28) fails to unmarshal the whole array. UpdateInboundClient reloads the target inbound's existing clients first (internal/web/service/client_inbound_apply.go:546), so this fails before your submitted changes are even applied — independent of what you actually changed.

On your two specific questions:

  • Shadowsocks vs VLESS: TgID and the parser above are shared by every protocol, so this is per-inbound, not per-protocol. It means your Shadowsocks inbound has at least one client with a stale non-numeric tgId in its stored settings, while your VLESS inbound(s) don't — it isn't Shadowsocks-specific.
  • Is this a regression in the latest release: behaviorally yes, although the bad data itself predates 3.5.0. Comparing GetClients between the v3.4.2 tag and current source: in v3.4.2, GetClients (then in internal/web/service/inbound.go) discarded the unmarshal error (_ = json.Unmarshal([]byte(inbound.Settings), &settings)) and silently returned whatever partial data resulted, so a stale tgId was tolerated silently. In the current source, GetClients (internal/web/service/inbound.go:442) instead calls ParseInboundSettingsClients, which correctly propagates that same error rather than swallowing it. So the pre-existing bad data only starts blocking edits after upgrading past that refactor — downgrading doesn't remove the bad data, it just goes back to silently ignoring it.

3x-ui ships a one-shot migration meant to heal this (normalizeInboundClientTgId, internal/database/db.go:1352, the InboundClientTgIdFix seeder) that should rewrite any non-numeric tgId to 0 on first startup after upgrade. #5934 lists the diagnostics to check whether that migration ran/completed for your database, plus a SQL workaround to unblock the affected inbound directly.

@MHSanaei for awareness — flagging the regression angle confirmed above (parser went from error-swallowing to error-propagating) as additional context on top of what's already tracked in #5934.

This reply was generated automatically. A maintainer may follow up.

<!-- gh-comment-id:4998167145 --> @github-actions[bot] commented on GitHub (Jul 17, 2026): This is the same underlying bug as #5934: identical error (`json: cannot unmarshal string into Go struct field Client.tgId of type int64`) on the same version (3.5.0). Closing as a duplicate to keep the discussion in one place — please follow #5934 for the full root-cause write-up and an unblocking workaround. **Root cause:** `model.Client.TgID` (`internal/database/model/model.go:817`) is a strict `int64`. If the affected inbound's stored `settings.clients[]` contains a client with a non-numeric legacy `tgId` (e.g. an old `""` value), `ParseInboundSettingsClients` (`internal/web/service/inbound_settings_clients.go:28`) fails to unmarshal the whole array. `UpdateInboundClient` reloads the target inbound's existing clients first (`internal/web/service/client_inbound_apply.go:546`), so this fails before your submitted changes are even applied — independent of what you actually changed. On your two specific questions: - **Shadowsocks vs VLESS:** `TgID` and the parser above are shared by every protocol, so this is per-inbound, not per-protocol. It means your Shadowsocks inbound has at least one client with a stale non-numeric `tgId` in its stored settings, while your VLESS inbound(s) don't — it isn't Shadowsocks-specific. - **Is this a regression in the latest release:** behaviorally yes, although the bad data itself predates 3.5.0. Comparing `GetClients` between the `v3.4.2` tag and current source: in `v3.4.2`, `GetClients` (then in `internal/web/service/inbound.go`) discarded the unmarshal error (`_ = json.Unmarshal([]byte(inbound.Settings), &settings)`) and silently returned whatever partial data resulted, so a stale `tgId` was tolerated silently. In the current source, `GetClients` (`internal/web/service/inbound.go:442`) instead calls `ParseInboundSettingsClients`, which correctly propagates that same error rather than swallowing it. So the pre-existing bad data only starts blocking edits after upgrading past that refactor — downgrading doesn't remove the bad data, it just goes back to silently ignoring it. 3x-ui ships a one-shot migration meant to heal this (`normalizeInboundClientTgId`, `internal/database/db.go:1352`, the `InboundClientTgIdFix` seeder) that should rewrite any non-numeric `tgId` to `0` on first startup after upgrade. #5934 lists the diagnostics to check whether that migration ran/completed for your database, plus a SQL workaround to unblock the affected inbound directly. @MHSanaei for awareness — flagging the regression angle confirmed above (parser went from error-swallowing to error-propagating) as additional context on top of what's already tracked in #5934. *This reply was generated automatically. A maintainer may follow up.*
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#4160
No description provided.