[GH-ISSUE #5783] [Bug]: XRAY: Failed to start: failed to decode config (cannot unmarshal string into Go / keepAlivePeriod of type int64 ) #4021

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

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

Describe the bug

XRAY: Failed to start after sub was updated

How to reproduce the problem

set "keepAlivePeriod": "10s" at streamSettings.finalmask.quicParams

Expected behavior

No response

Actual behavior

No response

Relevant logs

2026/07/04 11:46:39 ERROR - Failure in running xray-core:exit status 23
2026/07/04 11:46:39 ERROR - XRAY: Failed to start: main: failed to load config files: [bin/config.json] > infra/conf/serial: failed to decode config: &{Name:bin/config.json Format:json} > infra/conf/serial: failed to read config file at line 621 char 36 > json: cannot unmarshal string into Go struct field QuicParamsConfig.outbounds.streamSettings.finalmask.quicParams.keepAlivePeriod of type int64
2026/07/04 11:46:39 INFO - XRAY: infra/conf/serial: Reading config: &{Name:bin/config.json Format:json}

Screenshots

No response

3x-ui version

3.4.2

Xray-core version

26.6.27

How did you install 3x-ui?

install.sh script

Operating system

Linux raspberrypi 6.6.31+rpt-rpi-2712 #1 SMP PREEMPT Debian 1:6.6.31-1+rpt1 (2024-05-29) aarch64 GNU/Linux

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 @ecionis on GitHub (Jul 4, 2026). Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/5783 ### Describe the bug XRAY: Failed to start after sub was updated ### How to reproduce the problem set "keepAlivePeriod": "10s" at streamSettings.finalmask.quicParams ### Expected behavior _No response_ ### Actual behavior _No response_ ### Relevant logs ```shell 2026/07/04 11:46:39 ERROR - Failure in running xray-core:exit status 23 2026/07/04 11:46:39 ERROR - XRAY: Failed to start: main: failed to load config files: [bin/config.json] > infra/conf/serial: failed to decode config: &{Name:bin/config.json Format:json} > infra/conf/serial: failed to read config file at line 621 char 36 > json: cannot unmarshal string into Go struct field QuicParamsConfig.outbounds.streamSettings.finalmask.quicParams.keepAlivePeriod of type int64 2026/07/04 11:46:39 INFO - XRAY: infra/conf/serial: Reading config: &{Name:bin/config.json Format:json} ``` ### Screenshots _No response_ ### 3x-ui version 3.4.2 ### Xray-core version 26.6.27 ### How did you install 3x-ui? install.sh script ### Operating system Linux raspberrypi 6.6.31+rpt-rpi-2712 #1 SMP PREEMPT Debian 1:6.6.31-1+rpt1 (2024-05-29) aarch64 GNU/Linux ### 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:36:36 +07:00
Author
Owner

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

Confirmed from the log: xray-core requires streamSettings.finalmask.quicParams.keepAlivePeriod to be a plain JSON number of seconds (int64), not a duration string. A value like "10s" will always fail to decode — that field does not accept a unit suffix (unlike brutalUp/brutalDown in the same quicParams block, which genuinely are strings, e.g. "100 mbps"). This is consistent with frontend/src/schemas/protocols/stream/finalmask.ts:73 (keepAlivePeriod: z.number().int().min(2).max(60)) and the panel's own "Keep Alive Period (s)" field in FinalMaskForm.tsx:1156-1158, which is a plain number spinner — editing it through that field cannot produce a string.

So the string most likely entered the outbound config through one of two paths that currently skip type validation for finalmask/quicParams:

  1. Outbound Subscriptions (Xray Configs → Outbounds → Subscriptions tab). When a subscription is refreshed, internal/util/link/outbound.go's applyFinalMask() takes the fm= query parameter off each parsed share link and JSON-decodes it straight into streamSettings.finalmask with no type checking (internal/util/link/outbound.go:656-663). The refresh job then forces an Xray restart (internal/web/job/outbound_subscription_job.go), which matches "failed to start after sub was updated." The panel's own config merge (mergeSubscriptionOutbounds in internal/web/service/xray.go:596-625) treats outbounds as an opaque raw JSON blob, so nothing on the 3x-ui side re-validates field types — the only place that actually enforces keepAlivePeriod must be a number is xray-core itself at startup, which is the error you're seeing.
  2. Manually importing an outbound share link or editing an outbound's raw JSON tab in the panel (OutboundFormModal.tsx). Both paths bypass the Zod schema that would normally catch this (applyFinalMaskParam in frontend/src/lib/xray/outbound-link-parser.ts:215-226 copies fm= the same way, and form.validateFields() doesn't have a rule attached to keepAlivePeriod to reject a stray string).

To help pin down which path produced it:

  1. Do you have any Outbound Subscriptions configured (Xray Configs → Outbounds → Subscriptions), and if so, is the affected outbound one of theirs (tag prefix subN-)?
  2. If not, was this outbound created by pasting a share link ("Import Link") or by editing its JSON tab directly?

As an immediate workaround, open the affected outbound in the panel and re-enter Keep Alive Period as a plain number in the spinner (e.g. 10), then save — this will rewrite the field as an integer. If it's coming from a subscription, the bad value will return on the next refresh until the upstream provider's link stops sending it as a string.

This reply was generated automatically and a maintainer may follow up.

<!-- gh-comment-id:4881453502 --> @github-actions[bot] commented on GitHub (Jul 4, 2026): Confirmed from the log: xray-core requires `streamSettings.finalmask.quicParams.keepAlivePeriod` to be a plain JSON number of seconds (`int64`), not a duration string. A value like `"10s"` will always fail to decode — that field does not accept a unit suffix (unlike `brutalUp`/`brutalDown` in the same `quicParams` block, which genuinely are strings, e.g. `"100 mbps"`). This is consistent with `frontend/src/schemas/protocols/stream/finalmask.ts:73` (`keepAlivePeriod: z.number().int().min(2).max(60)`) and the panel's own "Keep Alive Period (s)" field in `FinalMaskForm.tsx:1156-1158`, which is a plain number spinner — editing it through that field cannot produce a string. So the string most likely entered the outbound config through one of two paths that currently skip type validation for `finalmask`/`quicParams`: 1. **Outbound Subscriptions** (Xray Configs → Outbounds → Subscriptions tab). When a subscription is refreshed, `internal/util/link/outbound.go`'s `applyFinalMask()` takes the `fm=` query parameter off each parsed share link and JSON-decodes it straight into `streamSettings.finalmask` with no type checking (`internal/util/link/outbound.go:656-663`). The refresh job then forces an Xray restart (`internal/web/job/outbound_subscription_job.go`), which matches "failed to start after sub was updated." The panel's own config merge (`mergeSubscriptionOutbounds` in `internal/web/service/xray.go:596-625`) treats outbounds as an opaque raw JSON blob, so nothing on the 3x-ui side re-validates field types — the only place that actually enforces `keepAlivePeriod` must be a number is xray-core itself at startup, which is the error you're seeing. 2. Manually **importing an outbound share link** or editing an outbound's raw JSON tab in the panel (`OutboundFormModal.tsx`). Both paths bypass the Zod schema that would normally catch this (`applyFinalMaskParam` in `frontend/src/lib/xray/outbound-link-parser.ts:215-226` copies `fm=` the same way, and `form.validateFields()` doesn't have a rule attached to `keepAlivePeriod` to reject a stray string). To help pin down which path produced it: 1. Do you have any Outbound Subscriptions configured (Xray Configs → Outbounds → Subscriptions), and if so, is the affected outbound one of theirs (tag prefix `subN-`)? 2. If not, was this outbound created by pasting a share link ("Import Link") or by editing its JSON tab directly? As an immediate workaround, open the affected outbound in the panel and re-enter `Keep Alive Period` as a plain number in the spinner (e.g. `10`), then save — this will rewrite the field as an integer. If it's coming from a subscription, the bad value will return on the next refresh until the upstream provider's link stops sending it as a string. *This reply was generated automatically and a maintainer may follow up.*
Author
Owner

@ecionis commented on GitHub (Jul 4, 2026):

I am using Outbound Subscriptions (not manual import)

<!-- gh-comment-id:4881471384 --> @ecionis commented on GitHub (Jul 4, 2026): I am using Outbound Subscriptions (not manual import)
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#4021
No description provided.