korbit-ai[bot] commented on code in PR #32025:
URL: https://github.com/apache/superset/pull/32025#discussion_r1933775498


##########
superset-frontend/src/dashboard/components/FiltersBadge/index.tsx:
##########
@@ -175,10 +175,10 @@ export const FiltersBadge = ({ chartId }: 
FiltersBadgeProps) => {
       setDashboardIndicators(indicatorsInitialState);
     } else if (prevChartStatus !== 'success') {
       if (
-        chart?.queriesResponse?.rejected_filters !==
-          prevChart?.queriesResponse?.rejected_filters ||
-        chart?.queriesResponse?.applied_filters !==
-          prevChart?.queriesResponse?.applied_filters ||
+        chart?.queriesResponse?.[0]?.rejected_filters !==
+          prevChart?.queriesResponse?.[0]?.rejected_filters ||
+        chart?.queriesResponse?.[0]?.applied_filters !==
+          prevChart?.queriesResponse?.[0]?.applied_filters ||

Review Comment:
   ### Missing empty array check for queriesResponse <sub>![category 
Functionality](https://img.shields.io/badge/Functionality-0284c7)</sub>
   
   <details>
     <summary>Tell me more</summary>
   
   ###### What is the issue?
   The code assumes queriesResponse array will always have at least one element 
without proper validation, which could lead to runtime errors if the array is 
empty.
   
   ###### Why this matters
   Accessing index [0] of an empty array will return undefined and could cause 
the component to fail silently or behave incorrectly when comparing filters.
   
   ###### Suggested change ∙ *Feature Preview*
   Add a length check before accessing the first element:
   ```typescript
   if (
           (chart?.queriesResponse?.length > 0 &&
             chart.queriesResponse[0]?.rejected_filters) !==
             (prevChart?.queriesResponse?.length > 0 &&
               prevChart.queriesResponse[0]?.rejected_filters) ||
           (chart?.queriesResponse?.length > 0 &&
             chart.queriesResponse[0]?.applied_filters) !==
             (prevChart?.queriesResponse?.length > 0 &&
               prevChart.queriesResponse[0]?.applied_filters)
   ```
   
   
   </details>
   
   <sub>💡 Does this comment miss the mark? [Tell us 
why](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/2020b553-6612-4dd9-bf9b-f4d799eac9cf?suggestedFixEnabled=true)
 and Korbit will adapt to your team’s feedback.
   💬 Chat with Korbit by mentioning @korbit-ai.
   </sub>
   
   <!--- korbi internal id:5755d8e1-e446-40a7-af3a-ad09afb94c61 -->
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to