[GH-ISSUE #5726] [Bug]: subJsonPath is generated without leading slash causing Zod validation failure #3985

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

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

Describe the bug

Version

3X-UI v3.4.2

Xray 26.6.27

Describe the bug

When editing HApp routing rules and clicking Save, the panel shows:

subJsonPath: pages.settings.validation.pathLeadingSlash
``

<img width="824" height="816" alt="Image" src="https://github.com/user-attachments/assets/29c824ef-8021-4569-90d4-d463a0291702" />

`

The browser console shows:

[zod] setting/all response failed validation


The problem is not related to HApp itself.

The backend returns an invalid value for `subJsonPath`.

## Current database value

```sql
subJsonPath|YIrCXJOOOL

Expected value

subJsonPath|/YIrCXJOOOL/

Root cause

The frontend validates subJsonPath and requires it to start with /.

The backend stores it without the leading slash.

Workaround

sqlite3 /etc/x-ui/x-ui.db

update settings
set value='/YIrCXJOOOL/'
where key='subJsonPath';

Restart x-ui:

systemctl restart x-ui

After that:

  • HApp settings are saved correctly.
  • Zod validation succeeds.
  • The error disappears.

Browser console

[zod] setting/all response failed validation

How to reproduce the problem

Workaround

sqlite3 /etc/x-ui/x-ui.db

update settings
set value='/YIrCXJOOOL/'
where key='subJsonPath';

Restart x-ui:

systemctl restart x-ui

After that:

  • HApp settings are saved correctly.
  • Zod validation succeeds.
  • The error disappears.

Expected behavior

No response

Actual behavior

No response

Relevant logs


Screenshots

Image

3x-ui version

3.4.2

Xray-core version

No response

How did you install 3x-ui?

Manual build from source

Operating system

Ubuntu 24.04

Which parts of the panel are affected?

Subscription (share links / Clash / JSON)

Browser (only if it is a UI bug)

No response

Is the panel behind a reverse proxy or CDN?

No response

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 @OlMat77 on GitHub (Jul 2, 2026). Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/5726 ### Describe the bug ## Version 3X-UI v3.4.2 Xray 26.6.27 ## Describe the bug When editing HApp routing rules and clicking Save, the panel shows: ``` subJsonPath: pages.settings.validation.pathLeadingSlash `` <img width="824" height="816" alt="Image" src="https://github.com/user-attachments/assets/29c824ef-8021-4569-90d4-d463a0291702" /> ` The browser console shows: ``` [zod] setting/all response failed validation ``` The problem is not related to HApp itself. The backend returns an invalid value for `subJsonPath`. ## Current database value ```sql subJsonPath|YIrCXJOOOL ``` ## Expected value ```sql subJsonPath|/YIrCXJOOOL/ ``` ## Root cause The frontend validates `subJsonPath` and requires it to start with `/`. The backend stores it without the leading slash. ## Workaround ```sql sqlite3 /etc/x-ui/x-ui.db update settings set value='/YIrCXJOOOL/' where key='subJsonPath'; ``` Restart x-ui: ```bash systemctl restart x-ui ``` After that: - HApp settings are saved correctly. - Zod validation succeeds. - The error disappears. ## Browser console ``` [zod] setting/all response failed validation ``` ### How to reproduce the problem ## Workaround ```sql sqlite3 /etc/x-ui/x-ui.db update settings set value='/YIrCXJOOOL/' where key='subJsonPath'; ``` Restart x-ui: ```bash systemctl restart x-ui ``` After that: - HApp settings are saved correctly. - Zod validation succeeds. - The error disappears. ### Expected behavior _No response_ ### Actual behavior _No response_ ### Relevant logs ```shell ``` ### Screenshots <img width="993" height="532" alt="Image" src="https://github.com/user-attachments/assets/4f1a367a-8288-431b-98ea-acdfeb55ecb6" /> ### 3x-ui version 3.4.2 ### Xray-core version _No response_ ### How did you install 3x-ui? Manual build from source ### Operating system Ubuntu 24.04 ### Which parts of the panel are affected? Subscription (share links / Clash / JSON) ### Browser (only if it is a UI bug) _No response_ ### Is the panel behind a reverse proxy or CDN? _No response_ ### 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:21 +07:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

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

Confirmed the root cause in source. This is the same underlying defect as #4946 and #5302, triggered by a different starting value (a legacy path without slashes instead of an empty string) — and it is still present in the current code, so it is worth tracking separately.

What is happening

  1. The Save button validates the whole settings form, not just the field you touched. onSave() in frontend/src/pages/settings/SettingsPage.tsx:126 runs AllSettingSchema.safeParse(allSetting) against the entire settings draft before allowing any save. subJsonPath (like subPath, subClashPath, webBasePath) must match ^\/ (frontend/src/schemas/setting.ts:5, used at line 47). Since your stored subJsonPath (YIrCXJOOOL) already lacked the leading slash, any edit anywhere on the Settings page — including unrelated routing rules — gets blocked by this pre-existing bad value.
  2. The backend returns path settings as-is, with no normalization on read. In internal/web/service/setting.go, GetAllSetting() copies string settings verbatim (fieldV.SetString(value) around line 212), unlike int/bool fields which fall back to defaults via effectiveSettingValue(). So whatever is in the settings table for subJsonPath is sent to the frontend unchanged.
  3. The backend does have self-healing logic, but it's unreachable here. AllSetting.CheckValid() (internal/web/entity/entity.go:229-234) auto-adds the missing leading/trailing slash to subJsonPath before persisting — but only when a save request actually reaches the server. Because step 1 blocks the request client-side, this normalization never gets a chance to run.
  4. The error message is unreadable because the translation key doesn't exist. pages.settings.validation.pathLeadingSlash is not defined in any file under internal/web/translation/ (checked all 13 locales), so i18next falls back to printing the raw key instead of a readable message.
  5. The [zod] setting/all response failed validation console line is a separate, non-blocking warning from frontend/src/utils/zodValidate.ts on the initial GET — it does not by itself prevent saving; the actual block is the save-time check described above.

As for how subJsonPath ended up without slashes in your database: GetAllSetting/CheckValid don't retroactively fix values that were already stored before this validation rule existed (or set by any means other than the current Settings-page save path), so a legacy value like this persists indefinitely and only surfaces once the frontend starts enforcing the leading-slash rule.

Workarounds

No SSH needed: on the Settings page, go to Subscription Settings → Subscription Formats → JSON Path field, click into it and then click/tab out (this fires the onBlur handler in frontend/src/pages/settings/SubscriptionFormatsTab.tsx:159, which calls normalizePath() and rewrites the value to something like /YIrCXJOOOL/), then Save.

Direct DB fix (what you already did):

sqlite3 /etc/x-ui/x-ui.db "UPDATE settings SET value='/YIrCXJOOOL/' WHERE key='subJsonPath';"
systemctl restart x-ui

It's also worth checking subPath and subClashPath for the same issue, since they use identical validation:

SELECT key, value FROM settings WHERE key IN ('subPath','subJsonPath','subClashPath','webBasePath');

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

<!-- gh-comment-id:4862937232 --> @github-actions[bot] commented on GitHub (Jul 2, 2026): Confirmed the root cause in source. This is the same underlying defect as #4946 and #5302, triggered by a different starting value (a legacy path without slashes instead of an empty string) — and it is still present in the current code, so it is worth tracking separately. ## What is happening 1. **The Save button validates the whole settings form, not just the field you touched.** `onSave()` in `frontend/src/pages/settings/SettingsPage.tsx:126` runs `AllSettingSchema.safeParse(allSetting)` against the *entire* settings draft before allowing any save. `subJsonPath` (like `subPath`, `subClashPath`, `webBasePath`) must match `^\/` (`frontend/src/schemas/setting.ts:5`, used at line 47). Since your stored `subJsonPath` (`YIrCXJOOOL`) already lacked the leading slash, any edit anywhere on the Settings page — including unrelated routing rules — gets blocked by this pre-existing bad value. 2. **The backend returns path settings as-is, with no normalization on read.** In `internal/web/service/setting.go`, `GetAllSetting()` copies string settings verbatim (`fieldV.SetString(value)` around line 212), unlike `int`/`bool` fields which fall back to defaults via `effectiveSettingValue()`. So whatever is in the `settings` table for `subJsonPath` is sent to the frontend unchanged. 3. **The backend *does* have self-healing logic, but it's unreachable here.** `AllSetting.CheckValid()` (`internal/web/entity/entity.go:229-234`) auto-adds the missing leading/trailing slash to `subJsonPath` before persisting — but only when a save request actually reaches the server. Because step 1 blocks the request client-side, this normalization never gets a chance to run. 4. **The error message is unreadable because the translation key doesn't exist.** `pages.settings.validation.pathLeadingSlash` is not defined in any file under `internal/web/translation/` (checked all 13 locales), so i18next falls back to printing the raw key instead of a readable message. 5. The `[zod] setting/all response failed validation` console line is a separate, non-blocking warning from `frontend/src/utils/zodValidate.ts` on the initial GET — it does not by itself prevent saving; the actual block is the save-time check described above. As for how `subJsonPath` ended up without slashes in your database: `GetAllSetting`/`CheckValid` don't retroactively fix values that were already stored before this validation rule existed (or set by any means other than the current Settings-page save path), so a legacy value like this persists indefinitely and only surfaces once the frontend starts enforcing the leading-slash rule. ## Workarounds **No SSH needed:** on the Settings page, go to **Subscription Settings → Subscription Formats → JSON Path** field, click into it and then click/tab out (this fires the `onBlur` handler in `frontend/src/pages/settings/SubscriptionFormatsTab.tsx:159`, which calls `normalizePath()` and rewrites the value to something like `/YIrCXJOOOL/`), then Save. **Direct DB fix (what you already did):** ```bash sqlite3 /etc/x-ui/x-ui.db "UPDATE settings SET value='/YIrCXJOOOL/' WHERE key='subJsonPath';" systemctl restart x-ui ``` It's also worth checking `subPath` and `subClashPath` for the same issue, since they use identical validation: ```sql SELECT key, value FROM settings WHERE key IN ('subPath','subJsonPath','subClashPath','webBasePath'); ``` *This reply was generated automatically; a maintainer may follow up.*
Author
Owner

@MHSanaei commented on GitHub (Jul 2, 2026):

Fixed in a335456c. Confirmed root cause: your stored subJsonPath predates the leading/trailing-slash rule, and the Settings page validates the whole form before any save — so the pre-existing bad value blocked every save (including unrelated HApp routing edits), while the backend's self-heal only runs on a save that never got sent. The panel now normalizes stored webBasePath/subPath/subJsonPath/subClashPath values at startup (idempotent, also covers restored backups), and the previously-missing pages.settings.validation.pathLeadingSlash translation was added to all 13 locales so the error reads properly if it ever appears again. Your SQL workaround is exactly what the startup fix now does automatically. Ships in the next release.

<!-- gh-comment-id:4865446979 --> @MHSanaei commented on GitHub (Jul 2, 2026): Fixed in a335456c. Confirmed root cause: your stored `subJsonPath` predates the leading/trailing-slash rule, and the Settings page validates the whole form before any save — so the pre-existing bad value blocked every save (including unrelated HApp routing edits), while the backend's self-heal only runs on a save that never got sent. The panel now normalizes stored `webBasePath`/`subPath`/`subJsonPath`/`subClashPath` values at startup (idempotent, also covers restored backups), and the previously-missing `pages.settings.validation.pathLeadingSlash` translation was added to all 13 locales so the error reads properly if it ever appears again. Your SQL workaround is exactly what the startup fix now does automatically. Ships in the next release.
Author
Owner

@OlMat77 commented on GitHub (Jul 2, 2026):

Thank you for the quick investigation and fix.
I can confirm that updating subJsonPath to include the leading slash immediately resolved the issue on my installation.
I appreciate both the startup normalization and the improved validation message. Great work!

<!-- gh-comment-id:4865499786 --> @OlMat77 commented on GitHub (Jul 2, 2026): Thank you for the quick investigation and fix. I can confirm that updating subJsonPath to include the leading slash immediately resolved the issue on my installation. I appreciate both the startup normalization and the improved validation message. Great work!
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#3985
No description provided.