codeant-ai-for-open-source[bot] commented on code in PR #40681:
URL: https://github.com/apache/superset/pull/40681#discussion_r3600480395


##########
superset-frontend/plugins/plugin-chart-ag-grid-table/src/transformProps.ts:
##########
@@ -193,7 +195,7 @@ const processComparisonDataRecords = memoizeOne(
               comparisonValue as number,
             );
 
-          transformedItem[`Main ${origCol.key}`] = originalValue;
+          transformedItem[`${t('Main')} ${origCol.key}`] = originalValue;

Review Comment:
   **Suggestion:** This key now depends on `t('Main')` inside a 
`memoizeOne`-cached function, but locale is not part of the memoization inputs. 
If the UI language changes while `originalData`/`originalColumns` references 
stay the same, cached rows keep the old-language key and stop matching newly 
generated columns, causing N/A values again. Include locale (or translated 
label) in the memoized function arguments, or avoid memoizing this 
locale-dependent transformation. [cache]
   
   <details>
   <summary><b>Severity Level:</b> Major ⚠️</summary>
   
   ```mdx
   - ❌ Time comparison Value column empty after runtime language switch.
   - ⚠️ Users see inconsistent labels and data after locale change.
   ```
   </details>
   <details>
   <summary><b>Steps of Reproduction ✅ </b></summary>
   
   ```mdx
   1. Render a Table V2 chart with time comparison enabled so that 
`AgGridTableChartPlugin`
   in `superset-frontend/plugins/plugin-chart-ag-grid-table/src/index.ts:15-26` 
instantiates
   the chart and uses `transformProps` as its transform function.
   
   2. With the UI language set to language A (for example English), load the 
chart so
   `transformProps` runs and calls `processComparisonDataRecords` (defined at
   
`superset-frontend/plugins/plugin-chart-ag-grid-table/src/transformProps.ts:172-178`),
   which builds `comparisonData` rows whose keys include 
`transformedItem[`${t('Main')}
   ${origCol.key}`]` at PR line 198 using the current translation of 
`t('Main')`.
   
   3. Change the UI language to language B (for example Russian) via Superset’s 
locale
   switcher while staying on the same Explore or dashboard view; Superset 
explicitly supports
   runtime language switching without reloading modules, as documented in
   `superset-frontend/eslint.config.minimal.js:9-12` where eager `t()` calls 
are warned
   against because labels “stay in the fallback language even after the user 
switches”.
   
   4. After the language switch, the chart re-renders and `transformProps` is 
invoked again
   with the same `baseQuery?.data` and `columns` references; 
`processComparisonColumns`
   (transformProps.ts:80-105) recomputes comparison columns with new keys 
`${t('Main')}
   ${col.key}` using the new-language `t('Main')`, but 
`processComparisonDataRecords` is
   memoized with `memoizeOne` (transformProps.ts:172) and returns its cached 
rows built under
   the old locale, whose keys still use the old-language `t('Main')` from line 
198, so the AG
   Grid column keys no longer match the row object properties and the “Value” 
column resolves
   `undefined`/N/A instead of the metric values.
   ```
   </details>
   
   [![Fix in 
Cursor](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-cursor-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=296a680dd17a49d4b57a7086d9b61fd1&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
 [![Fix in VSCode 
Claude](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-vscode-claude-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=296a680dd17a49d4b57a7086d9b61fd1&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
   
   *(Use Cmd/Ctrl + Click for best experience)*
   <details>
   <summary><b>Prompt for AI Agent 🤖 </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** 
superset-frontend/plugins/plugin-chart-ag-grid-table/src/transformProps.ts
   **Line:** 198:198
   **Comment:**
        *Cache: This key now depends on `t('Main')` inside a 
`memoizeOne`-cached function, but locale is not part of the memoization inputs. 
If the UI language changes while `originalData`/`originalColumns` references 
stay the same, cached rows keep the old-language key and stop matching newly 
generated columns, causing N/A values again. Include locale (or translated 
label) in the memoized function arguments, or avoid memoizing this 
locale-dependent transformation.
   
   Validate the correctness of the flagged issue. If correct, How can I resolve 
this? If you propose a fix, implement it and please make it concise.
   Once fix is implemented, also check other comments on the same PR, and ask 
user if the user wants to fix the rest of the comments as well. if said yes, 
then fetch all the comments validate the correctness and implement a minimal fix
   ```
   </details>
   <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F40681&comment_hash=8573ab8a90a3d29fefab3f4de0deb18033d91037a588b5bfbe75849e5a017f41&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F40681&comment_hash=8573ab8a90a3d29fefab3f4de0deb18033d91037a588b5bfbe75849e5a017f41&reaction=dislike'>👎</a>



-- 
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