mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-04 14:22:09 +03:00
fix: reject invalid provider cooldown bounds (#4589)
Integrated into release/v3.8.34 (rebuilt — bundled commits stripped)
This commit is contained in:
@@ -101,7 +101,20 @@ export const providerCooldownSettingsSchema = z
|
||||
minRetryCooldownMs: z.number().int().min(0).max(300000).optional(),
|
||||
maxRetryCooldownMs: z.number().int().min(0).max(3600000).optional(),
|
||||
})
|
||||
.strict();
|
||||
.strict()
|
||||
.superRefine((value, ctx) => {
|
||||
if (
|
||||
typeof value.minRetryCooldownMs === "number" &&
|
||||
typeof value.maxRetryCooldownMs === "number" &&
|
||||
value.maxRetryCooldownMs < value.minRetryCooldownMs
|
||||
) {
|
||||
ctx.addIssue({
|
||||
code: z.ZodIssueCode.custom,
|
||||
message: "maxRetryCooldownMs must be greater than or equal to minRetryCooldownMs",
|
||||
path: ["maxRetryCooldownMs"],
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
export const updateResilienceSchema = z
|
||||
.object({
|
||||
|
||||
@@ -41,6 +41,16 @@ describe("providerCooldown in updateResilienceSchema", () => {
|
||||
});
|
||||
assert.equal(result.success, false, "Schema should reject unknown keys");
|
||||
});
|
||||
|
||||
it("rejects providerCooldown max below min", () => {
|
||||
const result = updateResilienceSchema.safeParse({
|
||||
providerCooldown: {
|
||||
minRetryCooldownMs: 120000,
|
||||
maxRetryCooldownMs: 30000,
|
||||
},
|
||||
});
|
||||
assert.equal(result.success, false, "Schema should reject contradictory cooldown bounds");
|
||||
});
|
||||
});
|
||||
|
||||
describe("providerCooldown roundtrip through mergeResilienceSettings", () => {
|
||||
|
||||
Reference in New Issue
Block a user