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


##########
superset/dashboards/schemas.py:
##########
@@ -623,3 +623,21 @@ class CacheScreenshotSchema(Schema):
         fields.List(fields.Str(), validate=lambda x: len(x) == 2), 
required=False
     )
     permalinkKey = fields.Str(required=False)  # noqa: N815
+
+
+class DashboardExportXlsxPostSchema(Schema):

Review Comment:
   **Suggestion:** Add a concise class docstring immediately under this new 
schema class declaration to describe its request payload purpose. [custom_rule]
   
   **Severity Level:** Minor ⚠️
   <details>
   <summary><b>Why it matters? 🤔 </b></summary>
   
   This is a newly added Python class and it does not include a docstring 
immediately under the class definition. That matches the custom rule requiring 
new functions and classes to be documented inline.
   </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=ea1d45f8155842a7aefafdbf964b88a7&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=ea1d45f8155842a7aefafdbf964b88a7&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/dashboards/schemas.py
   **Line:** 628:628
   **Comment:**
        *Custom Rule: Add a concise class docstring immediately under this new 
schema class declaration to describe its request payload purpose.
   
   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%2F41133&comment_hash=6f51a4fe814c94ba7c396a1127e7c6bbc3e269cb11be5ce62fdb1874d2fd67cc&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41133&comment_hash=6f51a4fe814c94ba7c396a1127e7c6bbc3e269cb11be5ce62fdb1874d2fd67cc&reaction=dislike'>👎</a>



##########
tests/unit_tests/dashboards/test_excel_export_email.py:
##########
@@ -0,0 +1,98 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+from __future__ import annotations
+
+from datetime import datetime
+from unittest.mock import MagicMock, patch
+
+from superset.dashboards.excel_export import email
+
+REQUESTED = datetime(2026, 1, 1, 12, 0, 0)
+EXPIRES = datetime(2026, 1, 2, 12, 0, 0)
+
+
+def test_success_email_contains_link_and_expiry() -> None:
+    html = email.build_success_email(
+        dashboard_title="Sales",
+        download_url="https://signed.example/file.xlsx?sig=abc";,
+        requested_at=REQUESTED,
+        expires_at=EXPIRES,
+        ttl_seconds=86400,
+        skipped_charts=[],
+    )
+    assert "https://signed.example/file.xlsx?sig=abc"; in html
+    assert "expires in 24 hours" in html
+    assert "2026-01-02 12:00:00 UTC" in html
+    assert "2026-01-01 12:00:00 UTC" in html
+    assert "<li>" not in html  # no skipped section
+
+
+def test_success_email_lists_skipped_charts() -> None:

Review Comment:
   **Suggestion:** Add a concise docstring explaining that this test verifies 
skipped charts are rendered in the success email body. [custom_rule]
   
   **Severity Level:** Minor ⚠️
   <details>
   <summary><b>Why it matters? 🤔 </b></summary>
   
   This is a newly added Python test function and it lacks a docstring. That 
violates the rule requiring docstrings for new Python functions and classes.
   </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=9cc1976c101e43cabae6b0b049663ca0&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=9cc1976c101e43cabae6b0b049663ca0&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:** tests/unit_tests/dashboards/test_excel_export_email.py
   **Line:** 44:44
   **Comment:**
        *Custom Rule: Add a concise docstring explaining that this test 
verifies skipped charts are rendered in the success email body.
   
   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%2F41133&comment_hash=6b869c7f66660ac376cefe5cb11f84e18b9ae2adb02f132a184de9b043708a56&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41133&comment_hash=6b869c7f66660ac376cefe5cb11f84e18b9ae2adb02f132a184de9b043708a56&reaction=dislike'>👎</a>



##########
tests/unit_tests/dashboards/test_excel_export_email.py:
##########
@@ -0,0 +1,98 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+from __future__ import annotations
+
+from datetime import datetime
+from unittest.mock import MagicMock, patch
+
+from superset.dashboards.excel_export import email
+
+REQUESTED = datetime(2026, 1, 1, 12, 0, 0)
+EXPIRES = datetime(2026, 1, 2, 12, 0, 0)
+
+
+def test_success_email_contains_link_and_expiry() -> None:

Review Comment:
   **Suggestion:** Add a short docstring to this new test function describing 
the expected success-email content it validates. [custom_rule]
   
   **Severity Level:** Minor ⚠️
   <details>
   <summary><b>Why it matters? 🤔 </b></summary>
   
   This is a newly added Python test function and it has no docstring. The 
custom rule requires new Python functions and classes to include docstrings, so 
the suggestion identifies a real violation.
   </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=8b914eed91a44b829216ad03ab97380b&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=8b914eed91a44b829216ad03ab97380b&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:** tests/unit_tests/dashboards/test_excel_export_email.py
   **Line:** 28:28
   **Comment:**
        *Custom Rule: Add a short docstring to this new test function 
describing the expected success-email content it validates.
   
   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%2F41133&comment_hash=09cd2b56f973ccb8486426898c617966abe9e8297cb012ee5b26ee90ea597a2e&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41133&comment_hash=09cd2b56f973ccb8486426898c617966abe9e8297cb012ee5b26ee90ea597a2e&reaction=dislike'>👎</a>



##########
tests/unit_tests/dashboards/test_excel_export_layout.py:
##########
@@ -0,0 +1,105 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+from __future__ import annotations
+
+from typing import Any
+from unittest.mock import MagicMock
+
+from superset.dashboards.excel_export.layout import get_charts_in_layout_order
+
+
+def _chart_node(node_id: str, chart_id: int) -> dict[str, Any]:
+    return {"id": node_id, "type": "CHART", "meta": {"chartId": chart_id}}
+
+
+def _dashboard(position: dict[str, Any], chart_ids: list[int]) -> MagicMock:
+    dashboard = MagicMock()
+    dashboard.position = position
+    dashboard.slices = [MagicMock(id=cid) for cid in chart_ids]
+    return dashboard

Review Comment:
   **Suggestion:** Add a docstring explaining that this helper constructs a 
mocked dashboard object with position metadata and slice mocks. [custom_rule]
   
   **Severity Level:** Minor ⚠️
   <details>
   <summary><b>Why it matters? 🤔 </b></summary>
   
   This newly added helper function lacks a docstring. That violates the rule 
requiring new Python functions to include docstrings.
   </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=cefdcd6e11334c62a9deaceaa1ef50ab&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=cefdcd6e11334c62a9deaceaa1ef50ab&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:** tests/unit_tests/dashboards/test_excel_export_layout.py
   **Line:** 29:33
   **Comment:**
        *Custom Rule: Add a docstring explaining that this helper constructs a 
mocked dashboard object with position metadata and slice mocks.
   
   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%2F41133&comment_hash=5f7cfde3976d96d2ad1c1160d57521b13d35340a745a9328a67be02a178c9dde&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41133&comment_hash=5f7cfde3976d96d2ad1c1160d57521b13d35340a745a9328a67be02a178c9dde&reaction=dislike'>👎</a>



##########
tests/unit_tests/dashboards/test_excel_export_layout.py:
##########
@@ -0,0 +1,105 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+from __future__ import annotations
+
+from typing import Any
+from unittest.mock import MagicMock
+
+from superset.dashboards.excel_export.layout import get_charts_in_layout_order
+
+
+def _chart_node(node_id: str, chart_id: int) -> dict[str, Any]:
+    return {"id": node_id, "type": "CHART", "meta": {"chartId": chart_id}}
+
+
+def _dashboard(position: dict[str, Any], chart_ids: list[int]) -> MagicMock:
+    dashboard = MagicMock()
+    dashboard.position = position
+    dashboard.slices = [MagicMock(id=cid) for cid in chart_ids]
+    return dashboard
+
+
+def _ids(slices: list[Any]) -> list[int]:
+    return [slc.id for slc in slices]
+
+
+def test_grid_order() -> None:
+    position = {
+        "ROOT_ID": {"type": "ROOT", "children": ["GRID_ID"]},
+        "GRID_ID": {"type": "GRID", "children": ["ROW-1"]},
+        "ROW-1": {"type": "ROW", "children": ["CHART-a", "CHART-b"]},
+        "CHART-a": _chart_node("CHART-a", 1),
+        "CHART-b": _chart_node("CHART-b", 2),
+    }
+    dashboard = _dashboard(position, [2, 1])
+    assert _ids(get_charts_in_layout_order(dashboard)) == [1, 2]

Review Comment:
   **Suggestion:** Add a test docstring summarizing the behavior being 
validated for chart ordering in a basic grid layout. [custom_rule]
   
   **Severity Level:** Minor ⚠️
   <details>
   <summary><b>Why it matters? 🤔 </b></summary>
   
   Test functions are Python functions, and this newly added one does not 
include a docstring. The rule applies to newly added Python functions, so this 
is a real violation.
   </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=23b64aded0544a58b8cd843e811a374e&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=23b64aded0544a58b8cd843e811a374e&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:** tests/unit_tests/dashboards/test_excel_export_layout.py
   **Line:** 40:49
   **Comment:**
        *Custom Rule: Add a test docstring summarizing the behavior being 
validated for chart ordering in a basic grid layout.
   
   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%2F41133&comment_hash=84b81bd0bb8552a4bd268ffeaea88cba20197f53e9614e25b021371e58ddf073&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41133&comment_hash=84b81bd0bb8552a4bd268ffeaea88cba20197f53e9614e25b021371e58ddf073&reaction=dislike'>👎</a>



##########
tests/unit_tests/dashboards/test_excel_export_email.py:
##########
@@ -0,0 +1,98 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+from __future__ import annotations
+
+from datetime import datetime
+from unittest.mock import MagicMock, patch
+
+from superset.dashboards.excel_export import email
+
+REQUESTED = datetime(2026, 1, 1, 12, 0, 0)
+EXPIRES = datetime(2026, 1, 2, 12, 0, 0)
+
+
+def test_success_email_contains_link_and_expiry() -> None:
+    html = email.build_success_email(
+        dashboard_title="Sales",
+        download_url="https://signed.example/file.xlsx?sig=abc";,
+        requested_at=REQUESTED,
+        expires_at=EXPIRES,
+        ttl_seconds=86400,
+        skipped_charts=[],
+    )
+    assert "https://signed.example/file.xlsx?sig=abc"; in html
+    assert "expires in 24 hours" in html
+    assert "2026-01-02 12:00:00 UTC" in html
+    assert "2026-01-01 12:00:00 UTC" in html
+    assert "<li>" not in html  # no skipped section
+
+
+def test_success_email_lists_skipped_charts() -> None:
+    html = email.build_success_email(
+        dashboard_title="Sales",
+        download_url="https://x";,
+        requested_at=REQUESTED,
+        expires_at=EXPIRES,
+        ttl_seconds=86400,
+        skipped_charts=["10 - Broken chart"],
+    )
+    assert "no saved query context" in html
+    assert "<li>10 - Broken chart</li>" in html
+
+
+def test_success_email_escapes_title() -> None:
+    html = email.build_success_email(
+        dashboard_title="<script>alert(1)</script>",
+        download_url="https://x";,
+        requested_at=REQUESTED,
+        expires_at=EXPIRES,
+        ttl_seconds=86400,
+        skipped_charts=[],
+    )
+    assert "<script>" not in html
+    assert "&lt;script&gt;" in html
+
+
+def test_failure_email_body() -> None:
+    html = email.build_failure_email("Sales", REQUESTED)
+    assert "could not be completed" in html
+    assert "2026-01-01 12:00:00 UTC" in html
+
+
+@patch("superset.dashboards.excel_export.email.current_app")
+def test_build_subject(mock_app: MagicMock) -> None:

Review Comment:
   **Suggestion:** Add a docstring to this new test to describe that it 
validates subject formatting using the configured prefix. [custom_rule]
   
   **Severity Level:** Minor ⚠️
   <details>
   <summary><b>Why it matters? 🤔 </b></summary>
   
   This is a newly added Python test function and it does not have a docstring. 
The rule explicitly flags new Python functions without docstrings.
   </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=854e374c25624041bf0cfc67e4e9db2d&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=854e374c25624041bf0cfc67e4e9db2d&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:** tests/unit_tests/dashboards/test_excel_export_email.py
   **Line:** 77:77
   **Comment:**
        *Custom Rule: Add a docstring to this new test to describe that it 
validates subject formatting using the configured prefix.
   
   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%2F41133&comment_hash=d84f56d86c4e7e8642e26ffb4d44ef1f7d44a630e3b244af0eb47b570f76c3d3&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41133&comment_hash=d84f56d86c4e7e8642e26ffb4d44ef1f7d44a630e3b244af0eb47b570f76c3d3&reaction=dislike'>👎</a>



##########
tests/unit_tests/dashboards/test_excel_export_layout.py:
##########
@@ -0,0 +1,105 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+from __future__ import annotations
+
+from typing import Any
+from unittest.mock import MagicMock
+
+from superset.dashboards.excel_export.layout import get_charts_in_layout_order
+
+
+def _chart_node(node_id: str, chart_id: int) -> dict[str, Any]:
+    return {"id": node_id, "type": "CHART", "meta": {"chartId": chart_id}}
+
+
+def _dashboard(position: dict[str, Any], chart_ids: list[int]) -> MagicMock:
+    dashboard = MagicMock()
+    dashboard.position = position
+    dashboard.slices = [MagicMock(id=cid) for cid in chart_ids]
+    return dashboard
+
+
+def _ids(slices: list[Any]) -> list[int]:
+    return [slc.id for slc in slices]

Review Comment:
   **Suggestion:** Add a short docstring to clarify that this helper extracts 
and returns chart IDs from slice-like objects. [custom_rule]
   
   **Severity Level:** Minor ⚠️
   <details>
   <summary><b>Why it matters? 🤔 </b></summary>
   
   This is a new Python function without a docstring, so it matches the custom 
rule violation exactly.
   </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=d5abf8881b5d4a2ba4623b2a33eb755b&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=d5abf8881b5d4a2ba4623b2a33eb755b&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:** tests/unit_tests/dashboards/test_excel_export_layout.py
   **Line:** 36:37
   **Comment:**
        *Custom Rule: Add a short docstring to clarify that this helper 
extracts and returns chart IDs from slice-like objects.
   
   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%2F41133&comment_hash=cf509e544193a117860f6e43d40e73b7530f5a6e0deb11aa84b7985091c32981&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41133&comment_hash=cf509e544193a117860f6e43d40e73b7530f5a6e0deb11aa84b7985091c32981&reaction=dislike'>👎</a>



##########
tests/unit_tests/dashboards/test_excel_export_email.py:
##########
@@ -0,0 +1,98 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+from __future__ import annotations
+
+from datetime import datetime
+from unittest.mock import MagicMock, patch
+
+from superset.dashboards.excel_export import email
+
+REQUESTED = datetime(2026, 1, 1, 12, 0, 0)
+EXPIRES = datetime(2026, 1, 2, 12, 0, 0)
+
+
+def test_success_email_contains_link_and_expiry() -> None:
+    html = email.build_success_email(
+        dashboard_title="Sales",
+        download_url="https://signed.example/file.xlsx?sig=abc";,
+        requested_at=REQUESTED,
+        expires_at=EXPIRES,
+        ttl_seconds=86400,
+        skipped_charts=[],
+    )
+    assert "https://signed.example/file.xlsx?sig=abc"; in html
+    assert "expires in 24 hours" in html
+    assert "2026-01-02 12:00:00 UTC" in html
+    assert "2026-01-01 12:00:00 UTC" in html
+    assert "<li>" not in html  # no skipped section
+
+
+def test_success_email_lists_skipped_charts() -> None:
+    html = email.build_success_email(
+        dashboard_title="Sales",
+        download_url="https://x";,
+        requested_at=REQUESTED,
+        expires_at=EXPIRES,
+        ttl_seconds=86400,
+        skipped_charts=["10 - Broken chart"],
+    )
+    assert "no saved query context" in html
+    assert "<li>10 - Broken chart</li>" in html
+
+
+def test_success_email_escapes_title() -> None:
+    html = email.build_success_email(
+        dashboard_title="<script>alert(1)</script>",
+        download_url="https://x";,
+        requested_at=REQUESTED,
+        expires_at=EXPIRES,
+        ttl_seconds=86400,
+        skipped_charts=[],
+    )
+    assert "<script>" not in html
+    assert "&lt;script&gt;" in html
+
+
+def test_failure_email_body() -> None:

Review Comment:
   **Suggestion:** Add a brief docstring indicating this test validates the 
failure-email template content for unsuccessful exports. [custom_rule]
   
   **Severity Level:** Minor ⚠️
   <details>
   <summary><b>Why it matters? 🤔 </b></summary>
   
   This newly introduced test function has no docstring, so it violates the 
requirement that new Python functions and classes should be documented inline.
   </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=69cd2622b95c4a8fa4b4edb177432bd6&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=69cd2622b95c4a8fa4b4edb177432bd6&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:** tests/unit_tests/dashboards/test_excel_export_email.py
   **Line:** 70:70
   **Comment:**
        *Custom Rule: Add a brief docstring indicating this test validates the 
failure-email template content for unsuccessful exports.
   
   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%2F41133&comment_hash=7ce0152bc96c3c557fd51029a0b65ac18da775fefab7fc018d372060dd9c243a&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41133&comment_hash=7ce0152bc96c3c557fd51029a0b65ac18da775fefab7fc018d372060dd9c243a&reaction=dislike'>👎</a>



##########
tests/unit_tests/dashboards/test_excel_export_layout.py:
##########
@@ -0,0 +1,105 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+from __future__ import annotations
+
+from typing import Any
+from unittest.mock import MagicMock
+
+from superset.dashboards.excel_export.layout import get_charts_in_layout_order
+
+
+def _chart_node(node_id: str, chart_id: int) -> dict[str, Any]:
+    return {"id": node_id, "type": "CHART", "meta": {"chartId": chart_id}}
+
+
+def _dashboard(position: dict[str, Any], chart_ids: list[int]) -> MagicMock:
+    dashboard = MagicMock()
+    dashboard.position = position
+    dashboard.slices = [MagicMock(id=cid) for cid in chart_ids]
+    return dashboard
+
+
+def _ids(slices: list[Any]) -> list[int]:
+    return [slc.id for slc in slices]
+
+
+def test_grid_order() -> None:
+    position = {
+        "ROOT_ID": {"type": "ROOT", "children": ["GRID_ID"]},
+        "GRID_ID": {"type": "GRID", "children": ["ROW-1"]},
+        "ROW-1": {"type": "ROW", "children": ["CHART-a", "CHART-b"]},
+        "CHART-a": _chart_node("CHART-a", 1),
+        "CHART-b": _chart_node("CHART-b", 2),
+    }
+    dashboard = _dashboard(position, [2, 1])
+    assert _ids(get_charts_in_layout_order(dashboard)) == [1, 2]
+
+
+def test_tab_nested_order() -> None:
+    position = {
+        "ROOT_ID": {"type": "ROOT", "children": ["GRID_ID"]},
+        "GRID_ID": {"type": "GRID", "children": ["TABS-1"]},
+        "TABS-1": {"type": "TABS", "children": ["TAB-1", "TAB-2"]},
+        "TAB-1": {"type": "TAB", "children": ["CHART-a"]},
+        "TAB-2": {"type": "TAB", "children": ["CHART-b"]},
+        "CHART-a": _chart_node("CHART-a", 10),
+        "CHART-b": _chart_node("CHART-b", 20),
+    }
+    dashboard = _dashboard(position, [20, 10])
+    assert _ids(get_charts_in_layout_order(dashboard)) == [10, 20]

Review Comment:
   **Suggestion:** Add a docstring to this test function describing that nested 
tab layout traversal should preserve expected chart export order. [custom_rule]
   
   **Severity Level:** Minor ⚠️
   <details>
   <summary><b>Why it matters? 🤔 </b></summary>
   
   This newly added test function has no docstring, which violates the 
requirement that new Python functions be documented inline.
   </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=9c38ad936aff46b681b72bfeab23c58c&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=9c38ad936aff46b681b72bfeab23c58c&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:** tests/unit_tests/dashboards/test_excel_export_layout.py
   **Line:** 52:63
   **Comment:**
        *Custom Rule: Add a docstring to this test function describing that 
nested tab layout traversal should preserve expected chart export order.
   
   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%2F41133&comment_hash=20863f72719f9e85285f95a177b65af8b36fe254e81a7ba3fb4269bb05664376&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41133&comment_hash=20863f72719f9e85285f95a177b65af8b36fe254e81a7ba3fb4269bb05664376&reaction=dislike'>👎</a>



##########
tests/unit_tests/dashboards/test_excel_export_email.py:
##########
@@ -0,0 +1,98 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+from __future__ import annotations
+
+from datetime import datetime
+from unittest.mock import MagicMock, patch
+
+from superset.dashboards.excel_export import email
+
+REQUESTED = datetime(2026, 1, 1, 12, 0, 0)
+EXPIRES = datetime(2026, 1, 2, 12, 0, 0)
+
+
+def test_success_email_contains_link_and_expiry() -> None:
+    html = email.build_success_email(
+        dashboard_title="Sales",
+        download_url="https://signed.example/file.xlsx?sig=abc";,
+        requested_at=REQUESTED,
+        expires_at=EXPIRES,
+        ttl_seconds=86400,
+        skipped_charts=[],
+    )
+    assert "https://signed.example/file.xlsx?sig=abc"; in html
+    assert "expires in 24 hours" in html
+    assert "2026-01-02 12:00:00 UTC" in html
+    assert "2026-01-01 12:00:00 UTC" in html
+    assert "<li>" not in html  # no skipped section
+
+
+def test_success_email_lists_skipped_charts() -> None:
+    html = email.build_success_email(
+        dashboard_title="Sales",
+        download_url="https://x";,
+        requested_at=REQUESTED,
+        expires_at=EXPIRES,
+        ttl_seconds=86400,
+        skipped_charts=["10 - Broken chart"],
+    )
+    assert "no saved query context" in html
+    assert "<li>10 - Broken chart</li>" in html
+
+
+def test_success_email_escapes_title() -> None:

Review Comment:
   **Suggestion:** Add a docstring clarifying that this test checks HTML 
escaping behavior for unsafe dashboard titles. [custom_rule]
   
   **Severity Level:** Minor ⚠️
   <details>
   <summary><b>Why it matters? 🤔 </b></summary>
   
   The function is newly added and does not include a docstring. This matches 
the custom rule for documenting new Python functions.
   </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=2050cec11aca4ae588b75c5567510dee&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=2050cec11aca4ae588b75c5567510dee&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:** tests/unit_tests/dashboards/test_excel_export_email.py
   **Line:** 57:57
   **Comment:**
        *Custom Rule: Add a docstring clarifying that this test checks HTML 
escaping behavior for unsafe dashboard titles.
   
   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%2F41133&comment_hash=85575a109a5f1ad8e7b2131a30ede07a836afb6abef05dd4cc49cb9db490b56f&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41133&comment_hash=85575a109a5f1ad8e7b2131a30ede07a836afb6abef05dd4cc49cb9db490b56f&reaction=dislike'>👎</a>



##########
tests/unit_tests/dashboards/test_excel_export_layout.py:
##########
@@ -0,0 +1,105 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+from __future__ import annotations
+
+from typing import Any
+from unittest.mock import MagicMock
+
+from superset.dashboards.excel_export.layout import get_charts_in_layout_order
+
+
+def _chart_node(node_id: str, chart_id: int) -> dict[str, Any]:
+    return {"id": node_id, "type": "CHART", "meta": {"chartId": chart_id}}

Review Comment:
   **Suggestion:** Add a concise docstring to this helper function describing 
the chart node structure it builds for layout fixtures. [custom_rule]
   
   **Severity Level:** Minor ⚠️
   <details>
   <summary><b>Why it matters? 🤔 </b></summary>
   
   This is a newly added Python function and it has no docstring. The custom 
rule requires newly added functions to be documented inline, so the suggestion 
correctly identifies a real violation.
   </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=e0db1e3b65724cf599f5676877faa8ad&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=e0db1e3b65724cf599f5676877faa8ad&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:** tests/unit_tests/dashboards/test_excel_export_layout.py
   **Line:** 25:26
   **Comment:**
        *Custom Rule: Add a concise docstring to this helper function 
describing the chart node structure it builds for layout fixtures.
   
   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%2F41133&comment_hash=172f39951da49c5ea1fbe65d565895c4b31f4bd0f5cb940e754b21080935acdc&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41133&comment_hash=172f39951da49c5ea1fbe65d565895c4b31f4bd0f5cb940e754b21080935acdc&reaction=dislike'>👎</a>



##########
superset/tasks/export_dashboard_excel.py:
##########
@@ -0,0 +1,247 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+"""
+Celery task that exports every chart on a dashboard to a single multi-sheet
+``.xlsx`` file, uploads it to S3, and emails the requesting user a pre-signed
+download link.
+
+The task re-runs each chart's saved query context under the requesting user,
+applies the live dashboard filter state, and streams the results row-by-row 
into
+a constant-memory workbook so large dashboards never load all data at once.
+"""
+
+from __future__ import annotations
+
+import logging
+import os
+import tempfile
+from datetime import datetime, timedelta
+from typing import Any
+
+from celery.exceptions import SoftTimeLimitExceeded
+from flask import current_app, g
+
+from superset import db, security_manager
+from superset.charts.data.dashboard_filter_context import (
+    apply_extra_form_data_to_query_context_json,
+    get_dashboard_filter_context,
+)
+from superset.charts.schemas import ChartDataQueryContextSchema
+from superset.commands.chart.data.get_data_command import ChartDataCommand
+from superset.common.chart_data import ChartDataResultFormat, 
ChartDataResultType
+from superset.dashboards.excel_export import email
+from superset.dashboards.excel_export.layout import get_charts_in_layout_order
+from superset.extensions import celery_app
+from superset.utils import json, s3
+from superset.utils.core import override_user
+from superset.utils.excel_streaming import StreamingXlsxWriter
+
+logger = logging.getLogger(__name__)
+
+
+def _chart_label(chart: Any) -> str:
+    """Human-readable label for a chart in the skipped-charts list."""
+    return f"{chart.id} - {chart.slice_name or ''}".strip()
+
+
+def _record_to_row(record: dict[str, Any], colnames: list[str]) -> list[Any]:
+    return [record.get(col) for col in colnames]
+
+
+def _write_chart_sheets(
+    writer: StreamingXlsxWriter,
+    chart: Any,
+    dashboard_id: int,
+    active_data_mask: dict[str, Any],
+) -> None:
+    """
+    Run a single chart's query and stream its result(s) into the workbook.
+
+    Charts may yield more than one query (e.g. mixed-series charts); each 
becomes
+    its own sheet. Raises if the chart cannot be exported, so the caller can 
skip
+    it and note it in the email.
+    """
+    json_body = json.loads(chart.query_context)
+    # Override any stale saved values: we always want full JSON results.
+    json_body["result_format"] = ChartDataResultFormat.JSON
+    json_body["result_type"] = ChartDataResultType.FULL
+    json_body.pop("force", None)
+
+    filter_context = get_dashboard_filter_context(
+        dashboard_id=dashboard_id,
+        chart_id=chart.id,
+        active_data_mask=active_data_mask,
+    )
+    apply_extra_form_data_to_query_context_json(
+        json_body, filter_context.extra_form_data
+    )
+
+    # Jinja macros resolve form data from g.form_data; expose the saved 
context.
+    g.form_data = json_body
+
+    query_context = ChartDataQueryContextSchema().load(json_body)
+    command = ChartDataCommand(query_context)
+    command.validate()
+    result = command.run()
+
+    for index, query in enumerate(result["queries"]):
+        colnames = query.get("colnames") or []
+        data = query.get("data") or []
+        if index == 0:
+            name = f"{chart.id} - {chart.slice_name or ''}"
+        else:
+            name = f"{chart.id}.{index} - {chart.slice_name or ''}"
+        writer.add_sheet(
+            name,
+            colnames,
+            (_record_to_row(record, colnames) for record in data),
+        )
+
+
+def _build_workbook(
+    path: str,
+    dashboard: Any,
+    active_data_mask: dict[str, Any],
+    job_id: str,
+) -> list[str]:
+    """Build the workbook on disk; return the list of skipped chart labels."""
+    skipped: list[str] = []
+    writer = StreamingXlsxWriter(path)
+    try:
+        for chart in get_charts_in_layout_order(dashboard):
+            if not chart.query_context:
+                skipped.append(_chart_label(chart))
+                continue
+            try:
+                _write_chart_sheets(writer, chart, dashboard.id, 
active_data_mask)
+            except Exception:  # pylint: disable=broad-except
+                logger.exception(
+                    "Skipping chart %s in dashboard export %s", chart.id, 
job_id
+                )
+                skipped.append(_chart_label(chart))
+
+        if writer.sheet_count == 0:
+            writer.add_summary_sheet(
+                "Export Summary",
+                ["No chart data could be exported.", *skipped],
+            )
+    finally:
+        writer.close()
+    return skipped
+
+
+def _send_failure_email(
+    user: Any, dashboard_title: str, requested_at: datetime
+) -> None:
+    if not (user and getattr(user, "email", None)):
+        return

Review Comment:
   **Suggestion:** Add a docstring to this new function explaining when failure 
emails are sent and the purpose of its input parameters. [custom_rule]
   
   **Severity Level:** Minor ⚠️
   <details>
   <summary><b>Why it matters? 🤔 </b></summary>
   
   The function is newly added and does not include a docstring, so it matches 
the custom rule requiring docstrings for new Python functions and classes.
   </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=3fd5ba64b76e48e9a3827ae21ec43a8f&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=3fd5ba64b76e48e9a3827ae21ec43a8f&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/tasks/export_dashboard_excel.py
   **Line:** 147:151
   **Comment:**
        *Custom Rule: Add a docstring to this new function explaining when 
failure emails are sent and the purpose of its input parameters.
   
   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%2F41133&comment_hash=81fa8f4ea9a38425936805a666fb290da8ea04333a96edca41f036d35dffac1a&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41133&comment_hash=81fa8f4ea9a38425936805a666fb290da8ea04333a96edca41f036d35dffac1a&reaction=dislike'>👎</a>



##########
superset/dashboards/excel_export/email.py:
##########
@@ -0,0 +1,113 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+"""
+Email rendering and delivery for dashboard Excel exports.
+
+Bodies use inline styles only (no external CSS, no logo) to match Superset's
+existing report notification emails, and all user-controlled values (dashboard
+title, chart names) are HTML-escaped to avoid injection.
+"""
+
+from __future__ import annotations
+
+from datetime import datetime
+
+from flask import current_app
+from markupsafe import escape
+
+from superset.utils.core import send_email_smtp
+
+_DATETIME_FORMAT = "%Y-%m-%d %H:%M:%S"
+_FOOTER_STYLE = "color:#888;font-size:12px;"
+_BUTTON_STYLE = (
+    "display:inline-block;padding:10px 16px;background:#20a7c9;color:#ffffff;"
+    "text-decoration:none;border-radius:4px;"
+)
+
+
+def _fmt(dt: datetime) -> str:
+    return dt.strftime(_DATETIME_FORMAT)

Review Comment:
   **Suggestion:** Add a short docstring to this helper function describing 
that it formats a datetime using the module-level export timestamp format. 
[custom_rule]
   
   **Severity Level:** Minor ⚠️
   <details>
   <summary><b>Why it matters? 🤔 </b></summary>
   
   This is a newly added Python function in the new file, and it has no 
docstring.
   The custom rule requires newly added functions to be documented inline, so 
the
   suggestion correctly identifies a real violation.
   </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=337088129aaa4164910af9b7d0a5417c&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=337088129aaa4164910af9b7d0a5417c&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/dashboards/excel_export/email.py
   **Line:** 42:43
   **Comment:**
        *Custom Rule: Add a short docstring to this helper function describing 
that it formats a datetime using the module-level export timestamp format.
   
   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%2F41133&comment_hash=a765faadc3825103f5ee96e7856ace55310abde0b3ea5e19afb00bd59ee67d9b&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41133&comment_hash=a765faadc3825103f5ee96e7856ace55310abde0b3ea5e19afb00bd59ee67d9b&reaction=dislike'>👎</a>



##########
superset/dashboards/excel_export/email.py:
##########
@@ -0,0 +1,113 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+"""
+Email rendering and delivery for dashboard Excel exports.
+
+Bodies use inline styles only (no external CSS, no logo) to match Superset's
+existing report notification emails, and all user-controlled values (dashboard
+title, chart names) are HTML-escaped to avoid injection.
+"""
+
+from __future__ import annotations
+
+from datetime import datetime
+
+from flask import current_app
+from markupsafe import escape
+
+from superset.utils.core import send_email_smtp
+
+_DATETIME_FORMAT = "%Y-%m-%d %H:%M:%S"
+_FOOTER_STYLE = "color:#888;font-size:12px;"
+_BUTTON_STYLE = (
+    "display:inline-block;padding:10px 16px;background:#20a7c9;color:#ffffff;"
+    "text-decoration:none;border-radius:4px;"
+)
+
+
+def _fmt(dt: datetime) -> str:
+    return dt.strftime(_DATETIME_FORMAT)
+
+
+def build_subject(dashboard_title: str, *, success: bool) -> str:
+    """Build the email subject, prefixed with EMAIL_REPORTS_SUBJECT_PREFIX."""
+    prefix = current_app.config["EMAIL_REPORTS_SUBJECT_PREFIX"]
+    if success:
+        return f"{prefix}Your dashboard export is ready: {dashboard_title}"
+    return f"{prefix}Your dashboard export could not be completed: 
{dashboard_title}"
+
+
+def _skipped_section(skipped_charts: list[str]) -> str:
+    if not skipped_charts:
+        return ""
+    items = "".join(f"<li>{escape(label)}</li>" for label in skipped_charts)
+    return (
+        "<p>Note: the following charts were omitted because they have no saved 
"
+        "query context. To include them, open each chart in Explore and 
re-save."
+        f"</p><ul>{items}</ul>"
+    )

Review Comment:
   **Suggestion:** Add a docstring to this helper function that explains when 
skipped charts are rendered and what HTML fragment it returns. [custom_rule]
   
   **Severity Level:** Minor ⚠️
   <details>
   <summary><b>Why it matters? 🤔 </b></summary>
   
   This newly added helper function does not include a docstring.
   Because the rule requires new functions to be documented inline, the 
suggestion
   points to a genuine violation.
   </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=ad37e7b54092492eb7bcbc758002ff39&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=ad37e7b54092492eb7bcbc758002ff39&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/dashboards/excel_export/email.py
   **Line:** 54:62
   **Comment:**
        *Custom Rule: Add a docstring to this helper function that explains 
when skipped charts are rendered and what HTML fragment it returns.
   
   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%2F41133&comment_hash=c8bf48f5ee95e883af90fb74444ab475c6aaabed75362fa2900427225a259540&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41133&comment_hash=c8bf48f5ee95e883af90fb74444ab475c6aaabed75362fa2900427225a259540&reaction=dislike'>👎</a>



##########
superset/tasks/export_dashboard_excel.py:
##########
@@ -0,0 +1,247 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+"""
+Celery task that exports every chart on a dashboard to a single multi-sheet
+``.xlsx`` file, uploads it to S3, and emails the requesting user a pre-signed
+download link.
+
+The task re-runs each chart's saved query context under the requesting user,
+applies the live dashboard filter state, and streams the results row-by-row 
into
+a constant-memory workbook so large dashboards never load all data at once.
+"""
+
+from __future__ import annotations
+
+import logging
+import os
+import tempfile
+from datetime import datetime, timedelta
+from typing import Any
+
+from celery.exceptions import SoftTimeLimitExceeded
+from flask import current_app, g
+
+from superset import db, security_manager
+from superset.charts.data.dashboard_filter_context import (
+    apply_extra_form_data_to_query_context_json,
+    get_dashboard_filter_context,
+)
+from superset.charts.schemas import ChartDataQueryContextSchema
+from superset.commands.chart.data.get_data_command import ChartDataCommand
+from superset.common.chart_data import ChartDataResultFormat, 
ChartDataResultType
+from superset.dashboards.excel_export import email
+from superset.dashboards.excel_export.layout import get_charts_in_layout_order
+from superset.extensions import celery_app
+from superset.utils import json, s3
+from superset.utils.core import override_user
+from superset.utils.excel_streaming import StreamingXlsxWriter
+
+logger = logging.getLogger(__name__)
+
+
+def _chart_label(chart: Any) -> str:
+    """Human-readable label for a chart in the skipped-charts list."""
+    return f"{chart.id} - {chart.slice_name or ''}".strip()
+
+
+def _record_to_row(record: dict[str, Any], colnames: list[str]) -> list[Any]:

Review Comment:
   **Suggestion:** Add a concise docstring to this new helper function 
describing that it converts a record dictionary into a row ordered by the 
provided column names. [custom_rule]
   
   **Severity Level:** Minor ⚠️
   <details>
   <summary><b>Why it matters? 🤔 </b></summary>
   
   The function is newly added and has no docstring, which violates the rule 
that new Python functions should be documented inline.
   </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=8c3f545ae39b407fa602846ab5605331&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=8c3f545ae39b407fa602846ab5605331&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/tasks/export_dashboard_excel.py
   **Line:** 60:61
   **Comment:**
        *Custom Rule: Add a concise docstring to this new helper function 
describing that it converts a record dictionary into a row ordered by the 
provided column names.
   
   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%2F41133&comment_hash=e7ce91fa40442710b1f9ac38d56d5ea9c55ea0e92bf20d3a49363296a480e784&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41133&comment_hash=e7ce91fa40442710b1f9ac38d56d5ea9c55ea0e92bf20d3a49363296a480e784&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