[GH-ISSUE #5991] [Bug]: tgId Error in 3x-ui #4151

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

Originally created by @ariardiansyahputraz0 on GitHub (Jul 16, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/5991

Describe the bug

Solution: tgId Error in 3x-ui When Integrating with Telegram Bot

After extensive debugging and experimentation, the root cause turned out to be a version incompatibility in 3x-ui, not a bot code issue.

The error was:
cannot unmarshal string into Go struct field Client.tgId of type int64

cannot unmarshal string into Go struct field Client.tgId of type int64
The panel rejected all client creation/update requests with the tgId field, regardless of whether it was a string or integer.

How to reproduce the problem

cannot unmarshal string into Go struct field Client.tgId of type int64

Expected behavior

No response

Actual behavior

No response

Relevant logs


Screenshots

No response

3x-ui version

3.5.0

Xray-core version

No response

How did you install 3x-ui?

Other (please describe in the bug body)

Operating system

API

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 @ariardiansyahputraz0 on GitHub (Jul 16, 2026). Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/5991 ### Describe the bug Solution: tgId Error in 3x-ui When Integrating with Telegram Bot After extensive debugging and experimentation, the root cause turned out to be a version incompatibility in 3x-ui, not a bot code issue. The error was: cannot unmarshal string into Go struct field Client.tgId of type int64 cannot unmarshal string into Go struct field Client.tgId of type int64 The panel rejected all client creation/update requests with the tgId field, regardless of whether it was a string or integer. ### How to reproduce the problem cannot unmarshal string into Go struct field Client.tgId of type int64 ### Expected behavior _No response_ ### Actual behavior _No response_ ### Relevant logs ```shell ``` ### Screenshots _No response_ ### 3x-ui version 3.5.0 ### Xray-core version _No response_ ### How did you install 3x-ui? Other (please describe in the bug body) ### Operating system API ### 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:33 +07:00
Author
Owner

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

This is the same underlying bug as #5934: same error (cannot unmarshal string into Go struct field Client.tgId of type int64) and same version (3.5.0).

Confirmed in the source: model.Client.TgID (internal/database/model/model.go:817) is a strict int64 with no tolerant unmarshal, so any inbound whose stored settings.clients[] contains a non-numeric legacy tgId (e.g. an old "" value) fails to parse in ParseInboundSettingsClients (internal/web/service/inbound_settings_clients.go:28). Both addInboundClient and UpdateInboundClient reload the target inbound's existing clients first (internal/web/service/client_inbound_apply.go:322 and :546), so one un-migrated client on an inbound breaks every subsequent add/update request on that inbound — independent of the tgId value you actually submit. That matches what you saw.

Please follow and continue on #5934, which has the full root-cause writeup and an immediate SQL workaround for unblocking an affected inbound. Closing this one as a duplicate to keep the discussion in one place.

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

<!-- gh-comment-id:4989690485 --> @github-actions[bot] commented on GitHub (Jul 16, 2026): This is the same underlying bug as #5934: same error (`cannot unmarshal string into Go struct field Client.tgId of type int64`) and same version (3.5.0). Confirmed in the source: `model.Client.TgID` (`internal/database/model/model.go:817`) is a strict `int64` with no tolerant unmarshal, so any inbound whose stored `settings.clients[]` contains a non-numeric legacy `tgId` (e.g. an old `""` value) fails to parse in `ParseInboundSettingsClients` (`internal/web/service/inbound_settings_clients.go:28`). Both `addInboundClient` and `UpdateInboundClient` reload the target inbound's existing clients first (`internal/web/service/client_inbound_apply.go:322` and `:546`), so one un-migrated client on an inbound breaks every subsequent add/update request on that inbound — independent of the `tgId` value you actually submit. That matches what you saw. Please follow and continue on #5934, which has the full root-cause writeup and an immediate SQL workaround for unblocking an affected inbound. Closing this one as a duplicate to keep the discussion in one place. *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#4151
No description provided.