codeant-ai-for-open-source[bot] commented on code in PR #43137:
URL: https://github.com/apache/superset/pull/43137#discussion_r3806903037
##########
superset-frontend/src/features/reports/ReportModal/index.tsx:
##########
@@ -189,8 +189,13 @@ function ReportModal({
active: true,
force_screenshot: false,
custom_width: currentReport.custom_width,
- dashboard: dashboardId,
- chart: chart?.id,
+ // A report belongs to either a chart or a dashboard, never both.
Explore can
+ // carry dashboard context even for a chart-scoped report, so send only
the
+ // entity that matches the creation method; a payload with both `chart`
and
+ // `dashboard` is rejected by the backend with a 422 error.
+ ...(creationMethod === CreationMethod.Charts
+ ? { chart: chart?.id }
+ : { dashboard: dashboardId }),
Review Comment:
**Suggestion:** The entity selection used for saving now follows
`creationMethod`, but `report` and `isEditMode` are still selected using
`dashboardId` first. In Explore, a chart opened from a dashboard passes both
values, so an existing dashboard report can populate `currentReport`; saving it
then sends a chart-only payload with `creation_method: charts` to the dashboard
report's ID, potentially re-associating or rejecting the wrong resource. Select
the existing report using the same scope and ID as this branch, or prevent the
edit path when the scopes differ. [api mismatch]
<details>
<summary><b>Severity Level:</b> Major ⚠️</summary>
```mdx
- ❌ Existing dashboard reports can be edited from chart Explore context.
- ❌ Report edits may target the wrong resource ID.
- ⚠️ Backend may reject mismatched scope updates.
```
</details>
[](https://docs.codeant.ai/cli/resolve-pr-comments-skill)
<details>
<summary><b>Prompt for AI Agent 🤖 </b></summary>
```mdx
This is a comment left during a code review.
**Path:** superset-frontend/src/features/reports/ReportModal/index.tsx
**Line:** 196:198
**Comment:**
*Api Mismatch: The entity selection used for saving now follows
`creationMethod`, but `report` and `isEditMode` are still selected using
`dashboardId` first. In Explore, a chart opened from a dashboard passes both
values, so an existing dashboard report can populate `currentReport`; saving it
then sends a chart-only payload with `creation_method: charts` to the dashboard
report's ID, potentially re-associating or rejecting the wrong resource. Select
the existing report using the same scope and ID as this branch, or prevent the
edit path when the scopes differ.
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%2F43137&comment_hash=84e4332c0c81f3e0ca203e713f1237d4787c960e3627b5340527b8ecfe24d61c&reaction=like'>👍</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F43137&comment_hash=84e4332c0c81f3e0ca203e713f1237d4787c960e3627b5340527b8ecfe24d61c&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]