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


##########
superset-frontend/src/pages/DashboardList/index.tsx:
##########
@@ -454,6 +476,11 @@ function DashboardList(props: DashboardListProps) {
       },
       {
         Cell: ({ row: { original } }: any) => {
+          // Verify owner or isAdmin
+          const allowEdit: boolean =
+            original.owners.map((o: Owner) => o.id).includes(user.userId) ||
+            isUserAdmin(user);

Review Comment:
   **Suggestion:** The new permission check dereferences `user.userId` without 
guarding for anonymous/undefined users. This can throw at render time when 
`user` is missing (a supported scenario in existing list-page tests), so the 
check should safely handle absent users before reading `userId`. [null pointer]
   
   <details>
   <summary><b>Severity Level:</b> Critical 🚨</summary>
   
   ```mdx
   - ❌ Dashboard list route can crash when bootstrap user is undefined.
   - ⚠️ Anonymous/embedded flows risk broken dashboards UI.
   ```
   </details>
   <details>
   <summary><b>Steps of Reproduction ✅ </b></summary>
   
   ```mdx
   1. Note that the bootstrap type allows an absent user: `BootstrapData.user` 
is optional
   and `BootstrapUser` includes `undefined` in
   `superset-frontend/src/types/bootstrapTypes.ts:63-65`, and the Redux user 
reducer defaults
   to `bootstrapData.user || {}` in 
`superset-frontend/src/views/store.ts:85-91`, showing
   `bootstrapData.user` may legitimately be `undefined` at startup.
   
   2. In the main app router, `RouteSwitch` passes this potentially undefined 
bootstrap user
   directly into page components via `<Component user={bootstrapData.user} 
{...props} />` at
   `superset-frontend/src/views/App.tsx:102`, with no guard ensuring `user` is 
non-null.
   
   3. Navigate to the dashboard list route `/dashboard/list/`, which is wired 
to the
   `DashboardList` component in `superset-frontend/src/views/routes.tsx:207` 
(`{ path:
   RoutePaths.DASHBOARD_LIST, Component: DashboardList }`), so `DashboardList` 
receives
   `user={bootstrapData.user}` and may see `user` as `undefined`.
   
   4. When `DashboardList` renders the Actions column cell, the code at
   `superset-frontend/src/pages/DashboardList/index.tsx:478-482` computes 
`allowEdit` using
   `original.owners.map((o: Owner) => o.id).includes(user.userId) || 
isUserAdmin(user);`; if
   `user` is `undefined` (per step 1–3), accessing `user.userId` throws a 
`TypeError` during
   render, causing the dashboard list page to fail to mount or be caught by the 
error
   boundary.
   ```
   </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=1e57cb1907f84c61ad5e40b7311e9fb7&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=1e57cb1907f84c61ad5e40b7311e9fb7&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/src/pages/DashboardList/index.tsx
   **Line:** 480:482
   **Comment:**
        *Null Pointer: The new permission check dereferences `user.userId` 
without guarding for anonymous/undefined users. This can throw at render time 
when `user` is missing (a supported scenario in existing list-page tests), so 
the check should safely handle absent users before reading `userId`.
   
   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%2F32995&comment_hash=fbb9a4158f161651f5a21707dec9b16c7a44c81e3520a3c82edf0abc45d9d212&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F32995&comment_hash=fbb9a4158f161651f5a21707dec9b16c7a44c81e3520a3c82edf0abc45d9d212&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