codeant-ai-for-open-source[bot] commented on code in PR #40530:
URL: https://github.com/apache/superset/pull/40530#discussion_r3326924966
##########
superset/commands/report/execute.py:
##########
@@ -289,19 +289,19 @@ def get_dashboard_urls(
except json.JSONDecodeError:
logger.debug("Anchor value is not a list, Fall back to
single tab")
- # Merge native_filters into existing urlParams instead of
- # overwriting — dashboard_state may already have urlParams
- # (e.g. standalone=true) that must be preserved.
- state: DashboardPermalinkState = {**dashboard_state}
- state["urlParams"] = self._merge_native_filters_into_url_params(
- state.get("urlParams"), native_filter_params
- )
- return [
- self._get_tab_url(
- state,
- user_friendly=user_friendly,
+ # Skip the permalink when there is nothing meaningful to encode —
+ # an empty dashboard_state falls through to the plain URL below.
+ if native_filter_params and native_filter_params != "()":
+ state: DashboardPermalinkState = {**dashboard_state}
+ state["urlParams"] =
self._merge_native_filters_into_url_params(
+ state.get("urlParams"), native_filter_params
)
- ]
+ return [
+ self._get_tab_url(
+ state,
+ user_friendly=user_friendly,
+ )
+ ]
Review Comment:
**Suggestion:** This guard only creates a permalink when
`native_filter_params` is non-empty, so dashboards that rely on other persisted
state (for example `urlParams` like `standalone=true`) now fall through to a
plain dashboard URL and lose that state. Include a check for meaningful
non-filter dashboard state (such as non-empty `urlParams`) before skipping
permalink generation. [logic error]
<details>
<summary><b>Severity Level:</b> Major ⚠️</summary>
```mdx
- ⚠️ Dashboard email reports ignore API-provided `urlParams` state.
- ⚠️ Screenshots may miss standalone or layout-related URL params.
```
</details>
<details>
<summary><b>Steps of Reproduction ✅ </b></summary>
```mdx
1. Configure a dashboard report schedule whose `extra["dashboard"]` contains
only
non-filter URL state, for example `{"anchor": "", "dataMask": None,
"activeTabs": None,
"urlParams": [["standalone", "true"]]}` and no `"nativeFilters"` (shape
documented for
`urlParams` in `docs/scripts/fix-openapi-spec.py:48-17` and used via
`ReportSchedule.extra` in `superset/reports/models.py:12`).
2. Enable `ALERT_REPORT_TABS` and `ALERT_REPORTS_FILTER` so that
`BaseReportState.get_dashboard_urls()` takes the tabs-aware path
(`superset/commands/report/execute.py:60-71`) and calls
`self._report_schedule.get_native_filters_params()`, which returns `"()"`
when there are
no native filters (`superset/reports/models.py:193-40`).
3. When `get_dashboard_urls()` executes the guarded fallback at
`superset/commands/report/execute.py:294-304`, the condition `if
native_filter_params and
native_filter_params != "()"` is false (because `native_filter_params ==
"()"`), so it
skips building a permalink state from `dashboard_state` (including its
`urlParams`) and
does not call `_get_tab_url()`.
4. Execution falls through to the non-tabs fallback block at
`superset/commands/report/execute.py:57-77`, which recomputes
`native_filter_params` and,
again seeing `"()"`, returns a plain dashboard URL via
`get_url_path("Superset.dashboard",
...)` at `superset/commands/report/execute.py:79-92;` the `urlParams` in
`extra["dashboard"]` (such as `standalone=true`) are never encoded, so
dashboard reports
lose that persisted URL state.
```
</details>
[Fix in
Cursor](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=710bcdf128ad48d5bdd4bf1d3fa2a0d1&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
| [Fix in VSCode
Claude](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=710bcdf128ad48d5bdd4bf1d3fa2a0d1&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/commands/report/execute.py
**Line:** 294:304
**Comment:**
*Logic Error: This guard only creates a permalink when
`native_filter_params` is non-empty, so dashboards that rely on other persisted
state (for example `urlParams` like `standalone=true`) now fall through to a
plain dashboard URL and lose that state. Include a check for meaningful
non-filter dashboard state (such as non-empty `urlParams`) before skipping
permalink generation.
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%2F40530&comment_hash=a45ef12bd6b81dafdf53ef75cb2f7ae3a497f39dc5354f6a9b5ed374ae61ac64&reaction=like'>👍</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F40530&comment_hash=a45ef12bd6b81dafdf53ef75cb2f7ae3a497f39dc5354f6a9b5ed374ae61ac64&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]