[GH-ISSUE #4946] [Bug]: subJsonPath: pages.settings.validation.pathLeadingSlash #3466

Closed
opened 2026-10-31 20:32:38 +07:00 by bsakaguchi · 4 comments
Owner

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

Describe the bug

When trying to make changes to the subscription information page, I get this error. All paths are correct, including the "/" in the path. Reinstalling the panel doesn't help, nor does completely reinstalling Ubuntu. I'm running version 3.2.7. Other servers are running version 3.2.6, and this error doesn't occur.

How to reproduce the problem

Image

Expected behavior

No response

Actual behavior

No response

Relevant logs


Screenshots

Image

3x-ui version

3.2.7

Xray-core version

26.6.1

How did you install 3x-ui?

install.sh script

Operating system

24.4

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?

Yes — Nginx

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 @AndreyKaller on GitHub (Jun 5, 2026). Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/4946 ### Describe the bug When trying to make changes to the subscription information page, I get this error. All paths are correct, including the "/" in the path. Reinstalling the panel doesn't help, nor does completely reinstalling Ubuntu. I'm running version 3.2.7. Other servers are running version 3.2.6, and this error doesn't occur. ### How to reproduce the problem <img width="1672" height="664" alt="Image" src="https://github.com/user-attachments/assets/5652eb83-68e0-48c6-a940-02c777c9b9db" /> ### Expected behavior _No response_ ### Actual behavior _No response_ ### Relevant logs ```shell ``` ### Screenshots <img width="1672" height="664" alt="Image" src="https://github.com/user-attachments/assets/85be319f-db57-4702-8365-1083c7aa1420" /> ### 3x-ui version 3.2.7 ### Xray-core version 26.6.1 ### How did you install 3x-ui? install.sh script ### Operating system 24.4 ### 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? Yes — Nginx ### 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:32:38 +07:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

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

Thanks for the detailed report. I traced the root cause in the source code.

What is happening

The error subJsonPath: pages.settings.validation.pathLeadingSlash means the frontend's Zod schema (frontend/src/schemas/setting.ts:46) is rejecting the value of subJsonPath because it is an empty string (""), which does not match the required leading-slash regex (/^\//).

There are two underlying problems:

1. Backend: empty string is returned as-is for string settings

In web/service/setting.go, GetAllSetting() applies effectiveSettingValue() (which falls back to the built-in default when the stored value is "") for int and bool fields — but not for string fields (line 175–176). So if subJsonPath is stored as "" in your database, the API returns "" to the frontend instead of the default "/json/".

The commit that fixed the empty-value crash for int/bool (fcc6787a) explicitly left string fields unchanged ("string getters are unchanged, so legitimately-empty string settings stay empty"), which creates this mismatch with the frontend schema.

2. Frontend: missing translation key causes raw key to be shown

pages.settings.validation.pathLeadingSlash does not exist in any translation file under web/translation/, so the error toast shows the raw i18n key instead of a readable message like "Path must start with /".


Immediate fix (server command)

Run the following on your server to restore the default path:

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

If you also have empty subPath or subClashPath, fix those too:

sqlite3 /etc/x-ui/x-ui.db "UPDATE settings SET value='/sub/'   WHERE key='subPath'   AND value='';"
sqlite3 /etc/x-ui/x-ui.db "UPDATE settings SET value='/clash/' WHERE key='subClashPath' AND value='';"
systemctl restart x-ui

UI-only workaround (no SSH needed)

  1. Go to Settings → Subscription Formats.
  2. Make sure JSON Subscription is enabled (toggle it on if it isn't — you can turn it back off after saving).
  3. Click into the JSON Path field. The onBlur handler in SubscriptionFormatsTab.tsx:159 calls normalizePath(), which converts any empty value to /json/. Even just clicking in and then clicking out of the field is enough.
  4. Save.

The fix should apply effectiveSettingValue to string path fields on the backend, or handle empty-string path values gracefully in the frontend schema (e.g. z.string().min(1).regex(...) or coerce "" to the default before validation). The missing translation key should also be added to en-US.json (and other locales).

<!-- gh-comment-id:4628753677 --> @github-actions[bot] commented on GitHub (Jun 5, 2026): Thanks for the detailed report. I traced the root cause in the source code. ## What is happening The error `subJsonPath: pages.settings.validation.pathLeadingSlash` means the frontend's Zod schema (`frontend/src/schemas/setting.ts:46`) is rejecting the value of `subJsonPath` because it is an **empty string** (`""`), which does not match the required leading-slash regex (`/^\//`). There are two underlying problems: **1. Backend: empty string is returned as-is for string settings** In `web/service/setting.go`, `GetAllSetting()` applies `effectiveSettingValue()` (which falls back to the built-in default when the stored value is `""`) for `int` and `bool` fields — but **not for `string` fields** (line 175–176). So if `subJsonPath` is stored as `""` in your database, the API returns `""` to the frontend instead of the default `"/json/"`. The commit that fixed the empty-value crash for int/bool ([fcc6787a](https://github.com/MHSanaei/3x-ui/commit/fcc6787a)) explicitly left string fields unchanged ("string getters are unchanged, so legitimately-empty string settings stay empty"), which creates this mismatch with the frontend schema. **2. Frontend: missing translation key causes raw key to be shown** `pages.settings.validation.pathLeadingSlash` does not exist in any translation file under `web/translation/`, so the error toast shows the raw i18n key instead of a readable message like "Path must start with /". --- ## Immediate fix (server command) Run the following on your server to restore the default path: ```bash sqlite3 /etc/x-ui/x-ui.db "UPDATE settings SET value='/json/' WHERE key='subJsonPath';" systemctl restart x-ui ``` If you also have empty `subPath` or `subClashPath`, fix those too: ```bash sqlite3 /etc/x-ui/x-ui.db "UPDATE settings SET value='/sub/' WHERE key='subPath' AND value='';" sqlite3 /etc/x-ui/x-ui.db "UPDATE settings SET value='/clash/' WHERE key='subClashPath' AND value='';" systemctl restart x-ui ``` --- ## UI-only workaround (no SSH needed) 1. Go to **Settings → Subscription Formats**. 2. Make sure **JSON Subscription** is enabled (toggle it on if it isn't — you can turn it back off after saving). 3. Click into the **JSON Path** field. The `onBlur` handler in `SubscriptionFormatsTab.tsx:159` calls `normalizePath()`, which converts any empty value to `/json/`. Even just clicking in and then clicking out of the field is enough. 4. Save. --- The fix should apply `effectiveSettingValue` to string path fields on the backend, or handle empty-string path values gracefully in the frontend schema (e.g. `z.string().min(1).regex(...)` or coerce `""` to the default before validation). The missing translation key should also be added to `en-US.json` (and other locales).
Author
Owner

@AndreyKaller commented on GitHub (Jun 5, 2026):

При попытке включить JSON нажимая на кнопку Save вылетает такая же ошибка. Он не дает сохранить изменения.
И не активирует кнопку перезапуска панели,внести изменения невозможно.

Image
<!-- gh-comment-id:4628824327 --> @AndreyKaller commented on GitHub (Jun 5, 2026): При попытке включить JSON нажимая на кнопку Save вылетает такая же ошибка. Он не дает сохранить изменения. И не активирует кнопку перезапуска панели,внести изменения невозможно. <img width="1674" height="656" alt="Image" src="https://github.com/user-attachments/assets/4e8da84a-05ca-44b1-a8a0-cfac00d1a330" />
Author
Owner

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

check your JSON URI Path

<!-- gh-comment-id:4629512152 --> @MHSanaei commented on GitHub (Jun 5, 2026): check your JSON URI Path
Author
Owner

@petryaevve commented on GitHub (Jul 6, 2026):

check your JSON URI Path

In new versions there is no JSON URI Path setting in Subscription menu

<!-- gh-comment-id:4889661039 --> @petryaevve commented on GitHub (Jul 6, 2026): > check your JSON URI Path In new versions there is no JSON URI Path setting in Subscription menu
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#3466
No description provided.