From 0add63984fe841e14ebcad69d973c769011b9dd3 Mon Sep 17 00:00:00 2001 From: MHSanaei Date: Sun, 5 Jul 2026 20:12:21 +0200 Subject: [PATCH] fix(ui): align the subUpdates limit with the backend and show the range The hand-written settings schema capped subUpdates at 168 while the backend (and the generated schema mirrored from it) accepts 0-525600. Anyone upgrading from 2.x with a stored value above 168 could no longer save any settings tab: the whole settings object is validated on every save, so the stale field blocked everything with an unexplained "Invalid input". Match the backend bounds and put them on the input so the limit is discoverable. Closes #5821 --- .../pages/settings/SubscriptionGeneralTab.tsx | 2 +- frontend/src/schemas/setting.ts | 2 +- frontend/src/test/setting-sub-updates.test.ts | 17 +++++++++++++++++ 3 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 frontend/src/test/setting-sub-updates.test.ts diff --git a/frontend/src/pages/settings/SubscriptionGeneralTab.tsx b/frontend/src/pages/settings/SubscriptionGeneralTab.tsx index 72f2c138c..a0ce07e31 100644 --- a/frontend/src/pages/settings/SubscriptionGeneralTab.tsx +++ b/frontend/src/pages/settings/SubscriptionGeneralTab.tsx @@ -79,7 +79,7 @@ export default function SubscriptionGeneralTab({ allSetting, updateSetting }: Su - updateSetting({ subUpdates: Number(v) || 0 })} /> diff --git a/frontend/src/schemas/setting.ts b/frontend/src/schemas/setting.ts index e7d39ba86..bc6f81321 100644 --- a/frontend/src/schemas/setting.ts +++ b/frontend/src/schemas/setting.ts @@ -53,7 +53,7 @@ export const AllSettingSchema = z.object({ restartXrayOnClientDisable: z.boolean().optional(), subCertFile: z.string().optional(), subKeyFile: z.string().optional(), - subUpdates: z.number().int().min(1).max(168).optional(), + subUpdates: z.number().int().min(0).max(525600).optional(), subEncrypt: z.boolean().optional(), subURI: z.string().optional(), subJsonURI: z.string().optional(), diff --git a/frontend/src/test/setting-sub-updates.test.ts b/frontend/src/test/setting-sub-updates.test.ts new file mode 100644 index 000000000..56849896b --- /dev/null +++ b/frontend/src/test/setting-sub-updates.test.ts @@ -0,0 +1,17 @@ +import { describe, it, expect } from 'vitest'; +import { AllSettingSchema } from '@/schemas/setting'; + +describe('subUpdates range', () => { + it('accepts values the backend allows (gte=0, lte=525600)', () => { + for (const v of [0, 12, 168, 720, 525600]) { + const r = AllSettingSchema.safeParse({ subUpdates: v }); + expect(r.success, `subUpdates=${v} should be valid`).toBe(true); + } + }); + + it('rejects values outside the backend range', () => { + for (const v of [-1, 525601, 1.5]) { + expect(AllSettingSchema.safeParse({ subUpdates: v }).success, `subUpdates=${v} should be invalid`).toBe(false); + } + }); +});