codeant-ai-for-open-source[bot] commented on code in PR #38722:
URL: https://github.com/apache/superset/pull/38722#discussion_r2981388326
##########
tests/unit_tests/commands/report/execute_test.py:
##########
@@ -405,6 +405,51 @@ def test_get_tab_url(
assert result == urllib.parse.urljoin(base_url,
"superset/dashboard/p/uri/")
+@patch(
+
"superset.commands.dashboard.permalink.create.CreateDashboardPermalinkCommand.run"
+)
+@with_feature_flags(ALERT_REPORT_TABS=False)
+def test_get_dashboard_urls_native_filters_without_tabs(
+ mock_run,
+ mocker: MockerFixture,
+ app,
+) -> None:
+ """Native filters should be applied even when ALERT_REPORT_TABS is
disabled."""
+ mock_report_schedule: ReportSchedule = mocker.Mock(spec=ReportSchedule)
Review Comment:
**Suggestion:** This test uses a mocked `ReportSchedule`, so
`get_native_filters_params()` is a mock method that returns a truthy
`MagicMock` by default. That makes the test pass even if native filters are not
actually parsed from `extra`, creating a false positive. Use a real
`ReportSchedule` instance so native filter params are computed from the
provided `nativeFilters` payload. [logic error]
<details>
<summary><b>Severity Level:</b> Major ⚠️</summary>
```mdx
- ⚠️ CI may miss native filter regression bugs.
- ⚠️ Report URL tests validate permalink, not filter parsing.
```
</details>
```suggestion
mock_report_schedule = ReportSchedule()
```
<details>
<summary><b>Steps of Reproduction ✅ </b></summary>
```mdx
1. Run `test_get_dashboard_urls_native_filters_without_tabs` in
`tests/unit_tests/commands/report/execute_test.py:412`; it creates
`mock_report_schedule`
via `mocker.Mock(spec=ReportSchedule)` at line 418.
2. The test calls `BaseReportState.get_dashboard_urls()` (line 447), which
calls
`self._report_schedule.get_native_filters_params()` in
`superset/commands/report/execute.py:297`.
3. Because `_report_schedule` is a mock, `get_native_filters_params()` is a
`MagicMock`
return (not real parsing from `extra`), and condition `if
native_filter_params and
native_filter_params != "()"` at `execute.py:298` evaluates truthy.
4. The test patches permalink creation
(`@patch(...CreateDashboardPermalinkCommand.run)`
at `execute_test.py:408-410`), so URL generation succeeds regardless of
whether native
filters were actually parsed.
5. Assertion only checks permalink presence (`assert "permalink_key" in
result[0]` at line
450), so the test passes without validating
`ReportSchedule.get_native_filters_params()`
behavior from `superset/reports/models.py:190-207`.
```
</details>
<details>
<summary><b>Prompt for AI Agent 🤖 </b></summary>
```mdx
This is a comment left during a code review.
**Path:** tests/unit_tests/commands/report/execute_test.py
**Line:** 418:418
**Comment:**
*Logic Error: This test uses a mocked `ReportSchedule`, so
`get_native_filters_params()` is a mock method that returns a truthy
`MagicMock` by default. That makes the test pass even if native filters are not
actually parsed from `extra`, creating a false positive. Use a real
`ReportSchedule` instance so native filter params are computed from the
provided `nativeFilters` payload.
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.
```
</details>
<a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F38722&comment_hash=929eeb008b2c2c3a77acbc347f5eb305b8f76d01127b46966afc48de2179f29e&reaction=like'>👍</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F38722&comment_hash=929eeb008b2c2c3a77acbc347f5eb305b8f76d01127b46966afc48de2179f29e&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]