Skip to content

Commit 2a47308

Browse files
committed
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 <[email protected]>
1 parent 7644187 commit 2a47308

2 files changed

Lines changed: 15 additions & 2 deletions

File tree

‎packages/system/dashboard/images/console/apps/console/src/components/observability/ProxyNotice.test.tsx‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,13 @@ describe("ProxyNotice", () => {
3838
expect(screen.getByRole("alert").textContent).toBe(`${message}.`)
3939
})
4040

41+
it("still advises a shorter range for a store limit whose own advice is for operators", () => {
42+
const message = "the number of matching timeseries exceeds 300000; either narrow down the search or increase -search.max* command-line flag values"
43+
render(<ProxyNotice what="Metrics" error={new ProxyError("limit", 422, message)} />)
44+
45+
expect(screen.getByRole("alert").textContent).toBe(`${message}. Choose a shorter range.`)
46+
})
47+
4148
it("shows the server message for a rejected query", () => {
4249
render(<ProxyNotice what="Logs" error={new ProxyError("bad-request", 400, "cannot parse query")} />)
4350

‎packages/system/dashboard/images/console/apps/console/src/components/observability/ProxyNotice.tsx‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ interface ProxyNoticeProps {
55
error: unknown
66
}
77

8+
// Remedies the observability proxy itself appends; vmselect's 422 text carries
9+
// advice for operators (raise -search.max* flags), so it still gets ours.
10+
const PROXY_REMEDIES = ["; use a shorter range", "; raise step"]
11+
812
function describe(what: ProxyNoticeProps["what"], error: unknown): { quiet: boolean; text: string } {
913
const lower = what.toLowerCase()
1014
if (!(error instanceof ProxyError)) {
@@ -20,8 +24,10 @@ function describe(what: ProxyNoticeProps["what"], error: unknown): { quiet: bool
2024
case "forbidden":
2125
return { quiet: false, text: `You do not have permission to read ${lower} here.` }
2226
case "limit":
23-
// The proxy puts its own remedy after "; " (e.g. "use a shorter range", "raise step").
24-
return { quiet: false, text: error.message.includes("; ") ? `${error.message}.` : `${error.message}. Choose a shorter range.` }
27+
return {
28+
quiet: false,
29+
text: PROXY_REMEDIES.some((r) => error.message.endsWith(r)) ? `${error.message}.` : `${error.message}. Choose a shorter range.`,
30+
}
2531
case "rate-limited":
2632
return { quiet: false, text: "Too many requests. Try again in a moment." }
2733
case "timeout":

0 commit comments

Comments
 (0)