mirror of
https://github.com/cozystack/cozystack.git
synced 2026-11-22 12:43:32 +09:00
fix(dashboard): advise a shorter range unless the proxy already did
Any "; " in a 422 message was taken as the proxy's own remedy, but the proxy passes vmselect's 422 bodies through, and their advice (raise the -search.max* flags) is for operators. Those lost the one thing a tenant can do. Only the remedies the proxy itself appends now replace the console's advice. Assisted-by: LLM Signed-off-by: ZverGuy <maximbel2003@gmail.com>
This commit is contained in:
1 parent
76441871b8
commit
2a473086cf
2 files changed
+15
-2
No files matched your search
+7
@@ -38,6 +38,13 @@ describe("ProxyNotice", () => {
|
||||
expect(screen.getByRole("alert").textContent).toBe(`${message}.`)
|
||||
})
|
||||
|
||||
it("still advises a shorter range for a store limit whose own advice is for operators", () => {
|
||||
const message = "the number of matching timeseries exceeds 300000; either narrow down the search or increase -search.max* command-line flag values"
|
||||
render(<ProxyNotice what="Metrics" error={new ProxyError("limit", 422, message)} />)
|
||||
|
||||
expect(screen.getByRole("alert").textContent).toBe(`${message}. Choose a shorter range.`)
|
||||
})
|
||||
|
||||
it("shows the server message for a rejected query", () => {
|
||||
render(<ProxyNotice what="Logs" error={new ProxyError("bad-request", 400, "cannot parse query")} />)
|
||||
|
||||
|
||||
+8
-2
@@ -5,6 +5,10 @@ interface ProxyNoticeProps {
|
||||
error: unknown
|
||||
}
|
||||
|
||||
// Remedies the observability proxy itself appends; vmselect's 422 text carries
|
||||
// advice for operators (raise -search.max* flags), so it still gets ours.
|
||||
const PROXY_REMEDIES = ["; use a shorter range", "; raise step"]
|
||||
|
||||
function describe(what: ProxyNoticeProps["what"], error: unknown): { quiet: boolean; text: string } {
|
||||
const lower = what.toLowerCase()
|
||||
if (!(error instanceof ProxyError)) {
|
||||
@@ -20,8 +24,10 @@ 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":
|
||||
// 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.` }
|
||||
return {
|
||||
quiet: false,
|
||||
text: PROXY_REMEDIES.some((r) => error.message.endsWith(r)) ? `${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