[GH-ISSUE #5638] [Bug]: State desynchronization between Balancer GUI and Advanced Xray Template (wipes out "observatory" and "fallback", causes exit status 23) #3930

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

Originally created by @regulareverydaynormalmazaf on GitHub (Jun 28, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/5638

Describe the bug

I encountered a critical issue while configuring a load balancer with the Observatory feature in 3x-ui.

The panel's backend constantly overwrites specific routing blocks, causing parameters to silently disappear. Surprisingly, the fallback parameter gets automatically deleted even when edited strictly inside the JSON template file itself. These configuration drops break core dependencies, subsequently leading to validation failures (exit status 23 / dependencies not resolved) upon Xray restart.

There are 4 problem scenarios described below:

  1. Xray Validation Failure: If you create a load balancer and specify the fallback parameter without having the observatory block created first, Xray completely fails to start (exit status 23) upon panel restart.

  2. Template Overwrite (Fallback Drop): If you try to configure everything simultaneously by adding both the observatory block and the balancer with fallback into the Advanced JSON template, the panel silently deletes the "fallback" line from the configuration file after saving. Any subsequent attempts to manually re-add the fallback string directly into the JSON template file result in it being instantly erased after save.

  3. Observatory Wipeout via GUI: If you then try to add the missing fallback parameter using the Balancer GUI instead, the manually created "observatory" block immediately disappears from both the web interface and the JSON configuration template — even without clicking Save or restarting the panel.

  4. Dashboard Bug: Even when the specific workaround sequence is applied and the failover logic actually functions as intended (verified via error logs when forcing a connection timeout), the Dashboard under Xray Metrics -> Observatory still mistakenly displays a placeholder text stating that the feature is not configured.

P.S.
Additionally, the instruction link inside the bug report template ("Please search existing issues...") currently leads to a 404 error page on GitHub.

How to reproduce the problem

  1. Go to Panel Settings -> Xray Configuration Template and paste a clean JSON config containing both an "observatory" block and a balancer with a "fallback": "direct" parameter. Click Save.
  2. Notice that the "fallback" line is immediately deleted from the template upon saving.
  3. Try to add the missing fallback parameter back by opening the Balancer GUI modal.
  4. Observe that the "observatory" block is instantly wiped out from the template and GUI, even without saving.

Expected behavior

  1. No Silent Drops: The panel should merge and preserve manually added configuration blocks (like "observatory") inside the Advanced Xray Template when interacting with or saving settings via the Balancer GUI.

  2. Persistent Fallback: The "fallback" string should not be automatically stripped from the JSON template if it is valid.

  3. Core Dependency Order: If a balancer requires an observatory block to resolve its fallback logic, the panel should validate their coexistence before generating the final file, rather than dropping parameters and causing an exit status 23 crash.

  4. Dashboard Sync: The Xray Metrics -> Observatory dashboard tab should correctly parse and display status metrics when the feature is active and functional in the running Xray instance.

Actual behavior

The Only Working Order of Steps (Workaround)
To make the setup work without crashes and avoid configuration drops, I had to strictly follow this exact sequence:

  1. Create and configure the balancer in the GUI with the fallback option selected, then click save.
  2. Go to the Advanced JSON Template, manually append the missing "observatory" block, and click save.
  3. Manually modify the routing rules inside the JSON template to use "balancerTag" instead of "outboundTag" for the required inbound connection.
  4. Restart the panel/Xray.

Relevant logs

Logs for the first scenario:
Jun 28 16:41:55 server /usr/local/x-ui/x-ui[2984962]: INFO - XRAY: infra/conf/serial: Reading config: &{Name:bin/config.json Format:json}
Jun 28 16:41:55 server /usr/local/x-ui/x-ui[2984962]: WARNING - XRAY: infra/conf: REALITY: Listening on non-443 ports may get your IP blocked by the GFW
Jun 28 16:41:55 server /usr/local/x-ui/x-ui[2984962]: ERROR - XRAY: Failed to start: main: failed to create server > core: not all dependencies are resolved.
Jun 28 16:41:55 server /usr/local/x-ui/x-ui[2984962]: ERROR - Failure in running xray-core: exit status 23

Screenshots

No response

3x-ui version

3.4.1

Xray-core version

26.6.22

How did you install 3x-ui?

install.sh script

Operating system

Ubuntu 24.04.4 LTS

Which parts of the panel are affected?

Xray config generation, Statistics / traffic counters

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 @regulareverydaynormalmazaf on GitHub (Jun 28, 2026). Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/5638 ### Describe the bug I encountered a critical issue while configuring a load balancer with the Observatory feature in 3x-ui. The panel's backend constantly overwrites specific routing blocks, causing parameters to silently disappear. Surprisingly, the fallback parameter gets automatically deleted even when edited strictly inside the JSON template file itself. These configuration drops break core dependencies, subsequently leading to validation failures (exit status 23 / dependencies not resolved) upon Xray restart. There are 4 problem scenarios described below: 1. **Xray Validation Failure**: If you create a load balancer and specify the fallback parameter without having the observatory block created first, Xray completely fails to start (exit status 23) upon panel restart. 2. **Template Overwrite (Fallback Drop)**: If you try to configure everything simultaneously by adding both the observatory block and the balancer with fallback into the Advanced JSON template, the panel silently deletes the "fallback" line from the configuration file after saving. Any subsequent attempts to manually re-add the fallback string directly into the JSON template file result in it being instantly erased after save. 3. **Observatory Wipeout via GUI**: If you then try to add the missing fallback parameter using the Balancer GUI instead, the manually created "observatory" block immediately disappears from both the web interface and the JSON configuration template — even without clicking Save or restarting the panel. 4. **Dashboard Bug**: Even when the specific workaround sequence is applied and the failover logic actually functions as intended (verified via error logs when forcing a connection timeout), the Dashboard under Xray Metrics -> Observatory still mistakenly displays a placeholder text stating that the feature is not configured. P.S. Additionally, the instruction link inside the bug report template ("Please search **existing issues**...") currently leads to a 404 error page on GitHub. ### How to reproduce the problem 1. Go to Panel Settings -> Xray Configuration Template and paste a clean JSON config containing both an "observatory" block and a balancer with a "fallback": "direct" parameter. Click Save. 2. Notice that the "fallback" line is immediately deleted from the template upon saving. 3. Try to add the missing fallback parameter back by opening the Balancer GUI modal. 4. Observe that the "observatory" block is instantly wiped out from the template and GUI, even without saving. ### Expected behavior 1. No Silent Drops: The panel should merge and preserve manually added configuration blocks (like "observatory") inside the Advanced Xray Template when interacting with or saving settings via the Balancer GUI. 2. Persistent Fallback: The "fallback" string should not be automatically stripped from the JSON template if it is valid. 3. Core Dependency Order: If a balancer requires an observatory block to resolve its fallback logic, the panel should validate their coexistence before generating the final file, rather than dropping parameters and causing an exit status 23 crash. 4. Dashboard Sync: The Xray Metrics -> Observatory dashboard tab should correctly parse and display status metrics when the feature is active and functional in the running Xray instance. ### Actual behavior **The Only Working Order of Steps (Workaround)** To make the setup work without crashes and avoid configuration drops, I had to strictly follow this exact sequence: 1. Create and configure the balancer in the GUI with the fallback option selected, then click save. 2. Go to the Advanced JSON Template, manually append the missing "observatory" block, and click save. 3. Manually modify the routing rules inside the JSON template to use "balancerTag" instead of "outboundTag" for the required inbound connection. 4. Restart the panel/Xray. ### Relevant logs ```shell Logs for the first scenario: Jun 28 16:41:55 server /usr/local/x-ui/x-ui[2984962]: INFO - XRAY: infra/conf/serial: Reading config: &{Name:bin/config.json Format:json} Jun 28 16:41:55 server /usr/local/x-ui/x-ui[2984962]: WARNING - XRAY: infra/conf: REALITY: Listening on non-443 ports may get your IP blocked by the GFW Jun 28 16:41:55 server /usr/local/x-ui/x-ui[2984962]: ERROR - XRAY: Failed to start: main: failed to create server > core: not all dependencies are resolved. Jun 28 16:41:55 server /usr/local/x-ui/x-ui[2984962]: ERROR - Failure in running xray-core: exit status 23 ``` ### Screenshots _No response_ ### 3x-ui version 3.4.1 ### Xray-core version 26.6.22 ### How did you install 3x-ui? install.sh script ### Operating system Ubuntu 24.04.4 LTS ### Which parts of the panel are affected? Xray config generation, Statistics / traffic counters ### 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:35:58 +07:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@github-actions[bot] commented on GitHub (Jun 28, 2026):

The four scenarios share a single root cause: a mismatch between the type of observatory xray-core requires for a random/roundRobin balancer with a fallbackTag and what gets placed in the template when the Advanced JSON editor is used instead of the Balancer GUI.

Background: two observatory types

xray-core has two observatory variants that serve different strategies:

Section in config Required by
observatory leastPing strategy
burstObservatory leastLoad strategy, or random/roundRobin with a non-empty fallbackTag

The panel's syncObservatories function (confirmed in frontend/src/pages/xray/balancers/balancer-helpers.ts) enforces this automatically, but only when a change is made through the Balancer GUI (it is called from onConfirm in BalancersTab.tsx). Edits made directly in the Advanced JSON template editor bypass syncObservatories entirely; the raw JSON is saved without any observatory reconciliation.


Scenario 1 — exit status 23 when fallbackTag is set but burstObservatory is absent

Confirmed code path: when xray-core starts with a random balancer whose fallbackTag is a non-empty string and no burstObservatory section exists, it calls RequireFeatures(Observatory) internally and aborts with not all dependencies are resolved (exit status 23). The comment at balancer-helpers.ts:34-46 documents exactly this xray-core behaviour, referencing issue #5605.

If the balancer is created or edited through the Balancer GUI with fallbackTag set, syncObservatories creates burstObservatory automatically and this error cannot occur via that path. The error occurs only when fallbackTag is added manually in the Advanced editor without simultaneously adding a matching burstObservatory block.

Scenario 2 — fallbackTag appearing to vanish after saving

The backend save pipeline (confirmed in internal/web/service/xray_setting.go:SaveXraySetting) preserves all JSON fields, including fallbackTag, through the EnsureStatsRouting step and the final saveSetting call. The field is also preserved by the Zod schema on the frontend (BalancerObjectSchema includes fallbackTag: z.string().optional(), confirmed in frontend/src/schemas/routing.ts). The template itself does not lose fallbackTag.

The most likely explanation for the observed "erasure" is Scenario 3 occurring first: if a balancer with manually-set fallbackTag is subsequently edited through the Balancer GUI, syncObservatories rewrites the balancer entry. If the fallbackTag value in the form's dropdown was blank (e.g., because the target outbound tag was not in the outboundTags list and the Select cleared it), wire.fallbackTag would be serialized as "", which hasFallback treats as no-fallback, and burstObservatory would be removed.

Scenario 3 — observatory block wiped when interacting with the Balancer GUI

Confirmed bug. When syncObservatories runs (triggered by clicking OK in the Balancer add/edit modal), it deletes the top-level observatory block if no leastPing balancer exists (balancer-helpers.ts:54-56):

if (leastPings.length > 0) {
  // keep/create observatory
} else {
  delete t.observatory;   // <-- wipes any manually-added observatory
}

A random balancer with fallbackTag requires burstObservatory, not observatory. If the user manually added an observatory block (the wrong type for this strategy), syncObservatories correctly removes it and creates burstObservatory instead. From the user's perspective, the observatory block disappears as soon as they confirm any GUI edit of the balancer.

This is intentional behaviour — syncObservatories enforces correctness — but the UI gives no indication that the manually-added observatory block is the wrong type for the configured strategy.

Scenario 4 — Dashboard "Observatory" tab showing placeholder despite feature working

The panel's metrics service reads observatory data from xray-core's /debug/vars endpoint under the JSON key "observatory" (internal/web/service/xray_metrics.go:173):

Observatory map[string]rawObsEntry `json:"observatory"`

If xray-core exposes burstObservatory data under a different key (e.g., "burstObservatory") in that endpoint, the panel would see an empty map and display the "not configured" placeholder. Whether that is the case for xray-core 26.6.22 requires checking against the xray-core source at that version, which is outside this codebase.


Working configuration procedure

To use a random balancer with fallback failover without hitting any of these issues:

  1. In the panel, go to Xray Settings → Balancers.
  2. Click Add balancer, set the tag, selector, strategy (Random), and select the fallback outbound from the Fallback dropdown in the form.
  3. Click OK. The panel calls syncObservatories, which creates the burstObservatory block automatically.
  4. Click Save on the main Xray Settings page.
  5. Xray restarts; the dependency is satisfied.

Do not mix manual observatory JSON blocks with the Balancer GUI for random/roundRobin strategies. If the Advanced editor and the Balancer GUI are used together for the same balancer, always use the GUI last so syncObservatories has the final word.

P.S. — broken link in the bug report template

The relative URL ../issues?q=is%3Aissue in .github/ISSUE_TEMPLATE/bug_report.yaml resolves incorrectly when the template is rendered in the GitHub UI, producing a 404. It should be an absolute URL: https://github.com/MHSanaei/3x-ui/issues?q=is%3Aissue.


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

<!-- gh-comment-id:4826620595 --> @github-actions[bot] commented on GitHub (Jun 28, 2026): The four scenarios share a single root cause: a mismatch between the type of observatory xray-core requires for a `random`/`roundRobin` balancer with a `fallbackTag` and what gets placed in the template when the Advanced JSON editor is used instead of the Balancer GUI. **Background: two observatory types** xray-core has two observatory variants that serve different strategies: | Section in config | Required by | |---|---| | `observatory` | `leastPing` strategy | | `burstObservatory` | `leastLoad` strategy, or `random`/`roundRobin` with a non-empty `fallbackTag` | The panel's `syncObservatories` function (confirmed in `frontend/src/pages/xray/balancers/balancer-helpers.ts`) enforces this automatically, but only when a change is made through the Balancer GUI (it is called from `onConfirm` in `BalancersTab.tsx`). Edits made directly in the Advanced JSON template editor bypass `syncObservatories` entirely; the raw JSON is saved without any observatory reconciliation. --- **Scenario 1 — exit status 23 when `fallbackTag` is set but `burstObservatory` is absent** Confirmed code path: when xray-core starts with a `random` balancer whose `fallbackTag` is a non-empty string and no `burstObservatory` section exists, it calls `RequireFeatures(Observatory)` internally and aborts with `not all dependencies are resolved` (exit status 23). The comment at `balancer-helpers.ts:34-46` documents exactly this xray-core behaviour, referencing issue #5605. If the balancer is created or edited through the Balancer GUI with `fallbackTag` set, `syncObservatories` creates `burstObservatory` automatically and this error cannot occur via that path. The error occurs only when `fallbackTag` is added manually in the Advanced editor without simultaneously adding a matching `burstObservatory` block. **Scenario 2 — `fallbackTag` appearing to vanish after saving** The backend save pipeline (confirmed in `internal/web/service/xray_setting.go:SaveXraySetting`) preserves all JSON fields, including `fallbackTag`, through the `EnsureStatsRouting` step and the final `saveSetting` call. The field is also preserved by the Zod schema on the frontend (`BalancerObjectSchema` includes `fallbackTag: z.string().optional()`, confirmed in `frontend/src/schemas/routing.ts`). The template itself does not lose `fallbackTag`. The most likely explanation for the observed "erasure" is Scenario 3 occurring first: if a balancer with manually-set `fallbackTag` is subsequently edited through the Balancer GUI, `syncObservatories` rewrites the balancer entry. If the `fallbackTag` value in the form's dropdown was blank (e.g., because the target outbound tag was not in the `outboundTags` list and the Select cleared it), `wire.fallbackTag` would be serialized as `""`, which `hasFallback` treats as no-fallback, and `burstObservatory` would be removed. **Scenario 3 — `observatory` block wiped when interacting with the Balancer GUI** Confirmed bug. When `syncObservatories` runs (triggered by clicking OK in the Balancer add/edit modal), it deletes the top-level `observatory` block if no `leastPing` balancer exists (`balancer-helpers.ts:54-56`): ```ts if (leastPings.length > 0) { // keep/create observatory } else { delete t.observatory; // <-- wipes any manually-added observatory } ``` A `random` balancer with `fallbackTag` requires `burstObservatory`, not `observatory`. If the user manually added an `observatory` block (the wrong type for this strategy), `syncObservatories` correctly removes it and creates `burstObservatory` instead. From the user's perspective, the `observatory` block disappears as soon as they confirm any GUI edit of the balancer. This is intentional behaviour — `syncObservatories` enforces correctness — but the UI gives no indication that the manually-added `observatory` block is the wrong type for the configured strategy. **Scenario 4 — Dashboard "Observatory" tab showing placeholder despite feature working** The panel's metrics service reads observatory data from xray-core's `/debug/vars` endpoint under the JSON key `"observatory"` (`internal/web/service/xray_metrics.go:173`): ```go Observatory map[string]rawObsEntry `json:"observatory"` ``` If xray-core exposes `burstObservatory` data under a different key (e.g., `"burstObservatory"`) in that endpoint, the panel would see an empty map and display the "not configured" placeholder. Whether that is the case for xray-core 26.6.22 requires checking against the xray-core source at that version, which is outside this codebase. --- **Working configuration procedure** To use a `random` balancer with fallback failover without hitting any of these issues: 1. In the panel, go to **Xray Settings → Balancers**. 2. Click **Add balancer**, set the tag, selector, strategy (`Random`), and select the fallback outbound from the **Fallback** dropdown in the form. 3. Click **OK**. The panel calls `syncObservatories`, which creates the `burstObservatory` block automatically. 4. Click **Save** on the main Xray Settings page. 5. Xray restarts; the dependency is satisfied. Do not mix manual `observatory` JSON blocks with the Balancer GUI for `random`/`roundRobin` strategies. If the Advanced editor and the Balancer GUI are used together for the same balancer, always use the GUI last so `syncObservatories` has the final word. **P.S. — broken link in the bug report template** The relative URL `../issues?q=is%3Aissue` in `.github/ISSUE_TEMPLATE/bug_report.yaml` resolves incorrectly when the template is rendered in the GitHub UI, producing a 404. It should be an absolute URL: `https://github.com/MHSanaei/3x-ui/issues?q=is%3Aissue`. --- *This reply was generated automatically; a maintainer may follow up.*
Author
Owner

@MHSanaei commented on GitHub (Jun 28, 2026):

wait for next version already fixed

<!-- gh-comment-id:4827586808 --> @MHSanaei commented on GitHub (Jun 28, 2026): wait for next version already fixed
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#3930
No description provided.