-
-
Notifications
You must be signed in to change notification settings - Fork 10.4k
fix(resilience): expose providerCooldown in GET+PATCH /api/resilience #3590
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
diegosouzapw
merged 1 commit into
release/v3.8.20
from
fix/3556-provider-cooldown-api-missing
Jun 10, 2026
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| /** | ||
| * Regression test for #3556 / fix: providerCooldown missing from GET+PATCH /api/resilience | ||
| * | ||
| * The ResilienceTab component fetches GET /api/resilience and expects a `providerCooldown` | ||
| * field; likewise PATCH must accept and persist it. Without both, the Settings → Resilience | ||
| * page crashes on load and cannot save the provider-cooldown configuration. | ||
| */ | ||
| import assert from "node:assert/strict"; | ||
| import { describe, it } from "node:test"; | ||
|
|
||
| // Validate the schema accepts providerCooldown | ||
| import { updateResilienceSchema } from "../../src/shared/validation/schemas.js"; | ||
| // Validate settings roundtrip | ||
| import { | ||
| resolveResilienceSettings, | ||
| mergeResilienceSettings, | ||
| } from "../../src/lib/resilience/settings.js"; | ||
|
|
||
| describe("providerCooldown in updateResilienceSchema", () => { | ||
| it("accepts a valid providerCooldown patch", () => { | ||
| const result = updateResilienceSchema.safeParse({ | ||
| providerCooldown: { | ||
| enabled: true, | ||
| minRetryCooldownMs: 3000, | ||
| maxRetryCooldownMs: 120000, | ||
| }, | ||
| }); | ||
| assert.equal(result.success, true, `Schema rejected valid patch: ${JSON.stringify(result)}`); | ||
| }); | ||
|
|
||
| it("accepts partial providerCooldown patch", () => { | ||
| const result = updateResilienceSchema.safeParse({ | ||
| providerCooldown: { enabled: false }, | ||
| }); | ||
| assert.equal(result.success, true, `Schema rejected partial patch: ${JSON.stringify(result)}`); | ||
| }); | ||
|
|
||
| it("rejects unknown keys inside providerCooldown", () => { | ||
| const result = updateResilienceSchema.safeParse({ | ||
| providerCooldown: { enabled: true, unknownKey: 42 }, | ||
| }); | ||
| assert.equal(result.success, false, "Schema should reject unknown keys"); | ||
| }); | ||
| }); | ||
|
|
||
| describe("providerCooldown roundtrip through mergeResilienceSettings", () => { | ||
| it("merges providerCooldown overrides correctly", () => { | ||
| const base = resolveResilienceSettings({}); | ||
| const merged = mergeResilienceSettings(base, { | ||
| providerCooldown: { enabled: true, minRetryCooldownMs: 2000 }, | ||
| }); | ||
| assert.equal(merged.providerCooldown.enabled, true); | ||
| assert.equal(merged.providerCooldown.minRetryCooldownMs, 2000); | ||
| // maxRetryCooldownMs should remain from default | ||
| assert.ok(merged.providerCooldown.maxRetryCooldownMs > 0); | ||
| }); | ||
|
|
||
| it("resolveResilienceSettings returns providerCooldown field", () => { | ||
| const settings = resolveResilienceSettings({}); | ||
| assert.ok("providerCooldown" in settings, "providerCooldown missing from resolved settings"); | ||
| assert.ok("enabled" in settings.providerCooldown); | ||
| assert.ok("minRetryCooldownMs" in settings.providerCooldown); | ||
| assert.ok("maxRetryCooldownMs" in settings.providerCooldown); | ||
| }); | ||
| }); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a discrepancy between the maximum limits enforced by this Zod schema and those allowed by the backend normalization logic in
src/lib/resilience/settings.ts:minRetryCooldownMs: Schema max is300000(5 minutes), but the backend allows up to3600000(1 hour).maxRetryCooldownMs: Schema max is3600000(1 hour), but the backend allows up to86400000(24 hours).This discrepancy will cause the API to reject valid configurations that the backend is fully capable of supporting. We should align the schema limits with the backend's normalization limits.
Additionally, we can add a refinement to ensure
minRetryCooldownMsis less than or equal tomaxRetryCooldownMswhen both are provided.