Skip to content

SigNoz is an open-source, OpenTelemetry-native observability platform for your team and their AI agents. Get logs, metrics, and traces in one tool with features like APM, distributed tracing, log management, infra monitoring, etc. Combined with SigNoz MCP and a native AI teammate (in SigNoz Cloud) it helps you build more resilient apps.

fix(dashboards): stop query cache collisions on public dashboards (#11935)

Ashwin Bhatkal71eabac1e7ac
diff --git a/frontend/src/container/PublicDashboardContainer/Panel.tsx b/frontend/src/container/PublicDashboardContainer/Panel.tsx
index 456b1850be..42508eb714 100644
--- a/frontend/src/container/PublicDashboardContainer/Panel.tsx
+++ b/frontend/src/container/PublicDashboardContainer/Panel.tsx
@@ -79,13 +79,11 @@ function Panel({
},
ENTITY_VERSION_V5,
{
- queryKey: [
- widget?.query,
- widget?.panelTypes,
- requestData,
- startTime,
- endTime,
- ],
+ // Public data is fetched by index and the payload redacts each widget's
+ // filters, so query bodies are identical across panels. Key on panel
+ // identity + time — the only inputs that determine the response — so
+ // panels don't collapse onto one cache entry.
+ queryKey: [widget?.id, index, startTime, endTime],
retry(failureCount, error): boolean {
if (
String(error).includes('status: error') &&
diff --git a/frontend/src/container/PublicDashboardContainer/__tests__/Panel.test.tsx b/frontend/src/container/PublicDashboardContainer/__tests__/Panel.test.tsx
new file mode 100644
index 0000000000..18cc0d17df
--- /dev/null
+++ b/frontend/src/container/PublicDashboardContainer/__tests__/Panel.test.tsx
@@ -0,0 +1,79 @@
+import { PANEL_TYPES } from 'constants/queryBuilder';
+import { render } from 'tests/test-utils';
+import { Widgets } from 'types/api/dashboard/getAll';
+
+import Panel from '../Panel';
+
+const useGetQueryRangeMock = jest.fn();
+
+jest.mock('hooks/queryBuilder/useGetQueryRange', () => ({
+ useGetQueryRange: (...args: unknown[]): unknown => {
+ useGetQueryRangeMock(...args);
+ return {
+ data: undefined,
+ isFetching: false,
+ isLoading: false,
+ isSuccess: true,
+ isError: false,
+ };
+ },
+}));
+
+jest.mock('container/GridCardLayout/GridCard/WidgetGraphComponent', () => ({
+ __esModule: true,
+ default: (): JSX.Element => <div data-testid="widget-graph" />,
+}));
+
+const buildWidget = (id: string): Widgets =>
+ ({
+ id,
+ panelTypes: PANEL_TYPES.LIST,
+ query: {
+ builder: {
+ queryData: [{ dataSource: 'logs', limit: 100, orderBy: [] }],
+ },
+ },
+ timePreferance: 'GLOBAL_TIME',
+ }) as unknown as Widgets;
+
+describe('Public dashboard Panel', () => {
+ beforeEach(() => {
+ useGetQueryRangeMock.mockClear();
+ });
+
+ it('keys each panel by widget id + index so identical queries do not collide (bug 5503)', () => {
+ render(
+ <>
+ <Panel
+ widget={buildWidget('widget-a')}
+ index={2}
+ dashboardId="dash-1"
+ startTime={100}
+ endTime={200}
+ />
+ <Panel
+ widget={buildWidget('widget-b')}
+ index={62}
+ dashboardId="dash-1"
+ startTime={100}
+ endTime={200}
+ />
+ </>,
+ );
+
+ const [callA, callB] = useGetQueryRangeMock.mock.calls;
+ const queryKeyA = callA[2].queryKey;
+ const metaA = callA[4];
+ const queryKeyB = callB[2].queryKey;
+ const metaB = callB[4];
+
+ // Key is panel identity + time only — the redacted query body is not part
+ // of it, so identical query bodies can't collapse two panels onto one key.
+ expect(queryKeyA).toStrictEqual(['widget-a', 2, 100, 200]);
+ expect(queryKeyB).toStrictEqual(['widget-b', 62, 100, 200]);
+ expect(queryKeyA).not.toStrictEqual(queryKeyB);
+
+ expect(metaA.widgetIndex).toBe(2);
+ expect(metaB.widgetIndex).toBe(62);
+ });
+});