mirror of
https://github.com/cozystack/cozystack.git
synced 2026-11-22 12:43:32 +09:00
fix(dashboard): keep the proxy's own advice on a limit refusal
The notice appended "Choose a shorter range." to every 422, so a message that already ended in "use a shorter range" said it twice and one that ended in "raise step" got advice that contradicted it. The console's own advice is now added only when the proxy gave none. Assisted-by: LLM Signed-off-by: ZverGuy <maximbel2003@gmail.com>
This commit is contained in:
1 parent
881eea5246
commit
9498c9bff5
2 files changed
+11
-1
No files matched your search
+9
@@ -29,6 +29,15 @@ describe("ProxyNotice", () => {
|
||||
expect(screen.getByRole("alert")).toHaveTextContent(text)
|
||||
})
|
||||
|
||||
it.each([
|
||||
"the application has more than 50 pods in this window; use a shorter range",
|
||||
"1200 points per series exceed the limit of 1000; raise step",
|
||||
])("does not add advice to a limit message that already carries its own: %s", (message) => {
|
||||
render(<ProxyNotice what="Metrics" error={new ProxyError("limit", 422, message)} />)
|
||||
|
||||
expect(screen.getByRole("alert").textContent).toBe(`${message}.`)
|
||||
})
|
||||
|
||||
it("shows the server message for a rejected query", () => {
|
||||
render(<ProxyNotice what="Logs" error={new ProxyError("bad-request", 400, "cannot parse query")} />)
|
||||
|
||||
|
||||
+2
-1
@@ -20,7 +20,8 @@ function describe(what: ProxyNoticeProps["what"], error: unknown): { quiet: bool
|
||||
case "forbidden":
|
||||
return { quiet: false, text: `You do not have permission to read ${lower} here.` }
|
||||
case "limit":
|
||||
return { quiet: false, text: `${error.message}. Choose a shorter range.` }
|
||||
// The proxy puts its own remedy after "; " (e.g. "use a shorter range", "raise step").
|
||||
return { quiet: false, text: error.message.includes("; ") ? `${error.message}.` : `${error.message}. Choose a shorter range.` }
|
||||
case "rate-limited":
|
||||
return { quiet: false, text: "Too many requests. Try again in a moment." }
|
||||
case "timeout":
|
||||
|
||||
Reference in new issue
Block a user