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: added safety checks for query data (#8088)

SagarRajput-75a602bbeb707
diff --git a/frontend/src/container/GridCardLayout/GridCard/index.tsx b/frontend/src/container/GridCardLayout/GridCard/index.tsx
index a9d58a13bc..fe8b1a39c1 100644
--- a/frontend/src/container/GridCardLayout/GridCard/index.tsx
+++ b/frontend/src/container/GridCardLayout/GridCard/index.tsx
@@ -191,8 +191,9 @@ function GridCardGraph({
const isLogsQuery = useMemo(
() =>
- requestData.query.builder.queryData.every(
- (query) => query.dataSource === DataSource.LOGS,
+ requestData?.query?.builder?.queryData?.length > 0 &&
+ requestData?.query?.builder?.queryData?.every(
+ (query) => query?.dataSource === DataSource.LOGS,
),
[requestData.query],
);
@@ -203,7 +204,7 @@ function GridCardGraph({
variables: getDashboardVariables(variables),
selectedTime: widget.timePreferance || 'GLOBAL_TIME',
globalSelectedInterval:
- widget.panelTypes === PANEL_TYPES.LIST && isLogsQuery
+ widget?.panelTypes === PANEL_TYPES.LIST && isLogsQuery
? 'custom'
: globalSelectedInterval,
start: customTimeRange?.startTime || start,
diff --git a/frontend/src/container/LogsPanelTable/LogsPanelComponent.tsx b/frontend/src/container/LogsPanelTable/LogsPanelComponent.tsx
index 7c55de0bfd..7c2b6d5b0a 100644
--- a/frontend/src/container/LogsPanelTable/LogsPanelComponent.tsx
+++ b/frontend/src/container/LogsPanelTable/LogsPanelComponent.tsx
@@ -108,7 +108,7 @@ function LogsPanelComponent({
...prev,
tableParams: {
pagination: {
- limit: widget.query.builder.queryData[0].limit || 0,
+ limit: widget.query?.builder?.queryData[0]?.limit || 0,
offset: newOffset < 0 ? 0 : newOffset,
},
},
diff --git a/frontend/src/container/NewWidget/index.tsx b/frontend/src/container/NewWidget/index.tsx
index af6b3cda35..8c384af6e5 100644
--- a/frontend/src/container/NewWidget/index.tsx
+++ b/frontend/src/container/NewWidget/index.tsx
@@ -105,9 +105,11 @@ function NewWidget({ selectedGraph }: NewWidgetProps): JSX.Element {
GlobalReducer
>((state) => state.globalTime);
- const isLogsQuery = currentQuery.builder.queryData.every(
- (query) => query.dataSource === DataSource.LOGS,
- );
+ const isLogsQuery =
+ currentQuery?.builder?.queryData?.length > 0 &&
+ currentQuery?.builder?.queryData?.every(
+ (query) => query?.dataSource === DataSource.LOGS,
+ );
const customGlobalSelectedInterval = useMemo(
() =>
@@ -358,7 +360,9 @@ function NewWidget({ selectedGraph }: NewWidgetProps): JSX.Element {
// this has been moved here from the left container
const [requestData, setRequestData] = useState<GetQueryResultsProps>(() => {
const updatedQuery = cloneDeep(stagedQuery || initialQueriesMap.metrics);
- updatedQuery.builder.queryData[0].pageSize = 10;
+ if (updatedQuery?.builder?.queryData?.[0]) {
+ updatedQuery.builder.queryData[0].pageSize = 10;
+ }
if (selectedWidget) {
if (selectedGraph === PANEL_TYPES.LIST) {
@@ -406,7 +410,9 @@ function NewWidget({ selectedGraph }: NewWidgetProps): JSX.Element {
if (stagedQuery) {
setIsLoadingPanelData(false);
const updatedStagedQuery = cloneDeep(stagedQuery);
- updatedStagedQuery.builder.queryData[0].pageSize = 10;
+ if (updatedStagedQuery?.builder?.queryData?.[0]) {
+ updatedStagedQuery.builder.queryData[0].pageSize = 10;
+ }
setRequestData((prev) => ({
...prev,
selectedTime: selectedTime.enum || prev.selectedTime,