[Bug]: Host SNI on a REALITY inbound puts serverNames in the JSON subscription, xray refuses to start it
Describe the bug
If a Host has an SNI set and its inbound uses REALITY, the JSON subscription gives the client outbound both serverName and the server-side serverNames list. Xray-core refuses to start a REALITY client that has serverNames, so every JSON-subscription client on that inbound fails to connect (Happ, v2rayN/v2rayNG in JSON mode, and anything else that loads the full Xray config).
Share links (vless://…&sni=…) and Clash are fine. The Clash renderer reads only serverName, so the extra key is ignored there.
How to reproduce the problem
- Create a VLESS + TCP + REALITY inbound, e.g.
serverNames: ["www.example.com"]. - Add a Host for it with Security =
realityand SNI =www.example.org. - Fetch the JSON subscription (
/json/<subId>, or the sub URL with a Happ user agent). - Load the config into Xray-core, or import it into Happ.
Expected behavior
The client outbound's realitySettings has only serverName: "www.example.org".
Actual behavior
"realitySettings": {
"fingerprint": "chrome",
"publicKey": "…",
"serverName": "www.example.org",
"serverNames": ["www.example.org"],
"shortId": "abcd",
"show": false,
"spiderX": "/3ba18f06db21d4c"
}Xray-core (checked on 26.7.28 and 26.9.9):
Failed to start: main: failed to load config files: [...] > infra/conf: failed to build outbound config with tag proxy > infra/conf: failed to build stream settings for outbound detour > infra/conf: Failed to build REALITY config. > infra/conf: non-empty "serverNames", please use "serverName" insteadCause
applyHostStreamOverrides in internal/sub/host_sub.go ("Reality SNI override (host only)") sets both serverName and serverNames. The comment says the JSON realityData reads serverNames, but both SubJsonService.getConfig and the Clash renderer run streamData → realityData before applyHostStreamOverrides. By then the stream is already in client form, so serverNames is never read and ends up in the output as a server-only key.
Relevant logs
We hit this in production. Changing a REALITY host's SNI broke every Happ user on that inbound until the host SNI was cleared. We reproduced it on a clean 3.8.0 master + 3.8.5 node pair, and in a unit test on main (8c023d1). Fix: #6691.
Screenshots
The same REALITY inbound + host (SNI www.example.org) rendered through GetJson on main (before.json) and on the fix branch (after.json), then loaded with xray run -test:

3x-ui version
3.8.5 (also 3.8.0; unchanged on main @ 8c023d1)
Xray-core version
26.7.28 / 26.9.9 (client side)
How did you install 3x-ui?
install.sh script
Operating system
Ubuntu 24.04
Which parts of the panel are affected?
Subscription (share links / Clash / JSON), Multi-node (sub-nodes)
Source: MHSanaei/3x-ui