codeant-ai-for-open-source[bot] commented on code in PR #41133:
URL: https://github.com/apache/superset/pull/41133#discussion_r3589603549
##########
superset/config.py:
##########
@@ -1442,6 +1442,27 @@ def sync_theme_logo_href(
# note: index option should not be overridden
EXCEL_EXPORT: dict[str, Any] = {}
+# ---------------------------------------------------
+# Dashboard "Export Data to Excel" (async, S3-backed)
+# ---------------------------------------------------
+# Destination S3 bucket for generated dashboard .xlsx exports. The feature is
+# disabled until this is set: the export endpoint returns 501 when it is None.
+EXCEL_EXPORT_S3_BUCKET: str | None = None
+# Key prefix for export objects: {prefix}{dashboard_id}/{job_id}.xlsx
+EXCEL_EXPORT_S3_KEY_PREFIX = "dashboard-exports/"
+# Lifetime (seconds) of the pre-signed download URL emailed to the user (24h).
+# Note: AWS S3 caps pre-signed URL lifetime at 7 days (604800 seconds); larger
+# values are rejected by S3, so keep this at or below that when using AWS.
+EXCEL_EXPORT_LINK_TTL_SECONDS = 86400
Review Comment:
**Suggestion:** Add an explicit type annotation to this new numeric
configuration constant. [custom_rule]
**Severity Level:** Minor ๐งน
<details>
<summary><b>Why it matters? โญ </b></summary>
This new numeric configuration constant is introduced without an explicit
type hint, even though it is annotatable as an integer, so the suggestion
accurately identifies a real type-hint rule violation.
</details>
<details>
<summary><b>Rule source ๐ </b></summary>
.cursor/rules/dev-standard.mdc (line 28)
</details>
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=8f0e29d7355c4a60968aff8b8ef95079&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
[](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=8f0e29d7355c4a60968aff8b8ef95079&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/config.py
**Line:** 1453:1456
**Comment:**
*Custom Rule: Add an explicit type annotation to this new numeric
configuration constant.
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=a3d23798fe1c8548d1f44c6fa264549ce55234173a8b22200eb326a4a2b9d7d5&reaction=like'>๐</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41133&comment_hash=a3d23798fe1c8548d1f44c6fa264549ce55234173a8b22200eb326a4a2b9d7d5&reaction=dislike'>๐</a>
##########
superset/config.py:
##########
@@ -1442,6 +1442,27 @@ def sync_theme_logo_href(
# note: index option should not be overridden
EXCEL_EXPORT: dict[str, Any] = {}
+# ---------------------------------------------------
+# Dashboard "Export Data to Excel" (async, S3-backed)
+# ---------------------------------------------------
+# Destination S3 bucket for generated dashboard .xlsx exports. The feature is
+# disabled until this is set: the export endpoint returns 501 when it is None.
+EXCEL_EXPORT_S3_BUCKET: str | None = None
+# Key prefix for export objects: {prefix}{dashboard_id}/{job_id}.xlsx
+EXCEL_EXPORT_S3_KEY_PREFIX = "dashboard-exports/"
Review Comment:
**Suggestion:** Add an explicit type annotation to this new configuration
constant. [custom_rule]
**Severity Level:** Minor ๐งน
<details>
<summary><b>Why it matters? โญ </b></summary>
This new module-level configuration constant is a string value that can be
explicitly annotated, but it is currently assigned without a type hint,
matching the custom rule violation.
</details>
<details>
<summary><b>Rule source ๐ </b></summary>
.cursor/rules/dev-standard.mdc (line 28)
</details>
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=ffa5356e23d740169166b4b7bfa42792&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
[](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=ffa5356e23d740169166b4b7bfa42792&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/config.py
**Line:** 1451:1452
**Comment:**
*Custom Rule: Add an explicit type annotation to this new configuration
constant.
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=f7f279cb933abb2d2f670b74cba5f0455c4f8a3cec973da8eb0bb4b107e3e2e6&reaction=like'>๐</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41133&comment_hash=f7f279cb933abb2d2f670b74cba5f0455c4f8a3cec973da8eb0bb4b107e3e2e6&reaction=dislike'>๐</a>
##########
superset/dashboards/excel_export/email.py:
##########
@@ -0,0 +1,180 @@
+# 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 flask_babel import gettext as __, ngettext
+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;"
+)
+
+# Reason keys under which the export task groups charts it could not export.
+# The task classifies each omitted chart under one of these; the email renders
a
+# separate, labelled section per non-empty group with its own remediation text.
+ERROR_NO_QUERY_CONTEXT = "no-query-context"
+ERROR_GENERAL = "general-exception"
+
+
+def _fmt(dt: datetime) -> str:
+ return dt.strftime(_DATETIME_FORMAT)
+
+
+def _humanize_ttl(seconds: int) -> str:
+ """Render a TTL as a human-readable, pluralized, translatable duration.
+
+ Whole hours read as "24 hours"; sub-hour and non-hour values keep their
+ minutes (e.g. "1 hour 30 minutes", "15 minutes") so the stated lifetime
+ always matches the real pre-signed URL expiration.
+ """
+ hours, remainder = divmod(seconds, 3600)
+ parts: list[str] = []
+ if hours:
+ parts.append(ngettext("%(num)d hour", "%(num)d hours", hours))
+ if minutes := remainder // 60:
+ parts.append(ngettext("%(num)d minute", "%(num)d minutes", minutes))
+ if not parts:
+ parts.append(ngettext("%(num)d second", "%(num)d seconds", seconds))
+ return " ".join(parts)
+
+
+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 prefix + __(
+ "Your dashboard export is ready: %(title)s", title=dashboard_title
+ )
+ return prefix + __(
+ "Your dashboard export could not be completed: %(title)s",
+ title=dashboard_title,
+ )
+
+
+def _errored_section(errored: dict[str, list[str]]) -> str:
+ """Render one labelled, translated sub-list per non-empty error group.
+
+ ``errored`` maps a reason key (see the ``ERROR_*`` constants) to the labels
+ of the charts that were omitted for that reason. Known reasons are rendered
+ first, in a stable order, each with its own remediation text; any unknown
+ reason key falls back to a generic message so nothing is silently dropped.
+ """
+ if not errored:
+ return ""
+ notes = {
+ ERROR_NO_QUERY_CONTEXT: __(
+ "The following charts were omitted because they have no saved
query "
+ "context. To include them, open each chart in Explore and re-save."
+ ),
+ ERROR_GENERAL: __(
+ "The following charts were omitted because an error occurred while
"
+ "exporting them:"
+ ),
+ }
+ fallback = __("The following charts could not be exported:")
+ ordered = [ERROR_NO_QUERY_CONTEXT, ERROR_GENERAL]
Review Comment:
**Suggestion:** Annotate this list variable with its element type to satisfy
the type-hint requirement for relevant local variables. [custom_rule]
**Severity Level:** Minor ๐งน
<details>
<summary><b>Why it matters? โญ </b></summary>
This is a local list variable in new Python code and it lacks an explicit
type hint even though its element type is known, matching the rule's
requirement.
</details>
<details>
<summary><b>Rule source ๐ </b></summary>
.cursor/rules/dev-standard.mdc (line 28)
</details>
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=8d632c04aac143f794a665b5a8ca4d18&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
[](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=8d632c04aac143f794a665b5a8ca4d18&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:** 105:105
**Comment:**
*Custom Rule: Annotate this list variable with its element type to
satisfy the type-hint requirement for relevant local variables.
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=58d3d3aebcd6508cb5513cdbe97524c6f056cbd69e24a52918f1268888be51d2&reaction=like'>๐</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41133&comment_hash=58d3d3aebcd6508cb5513cdbe97524c6f056cbd69e24a52918f1268888be51d2&reaction=dislike'>๐</a>
##########
superset/dashboards/excel_export/email.py:
##########
@@ -0,0 +1,180 @@
+# 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 flask_babel import gettext as __, ngettext
+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;"
+)
+
+# Reason keys under which the export task groups charts it could not export.
+# The task classifies each omitted chart under one of these; the email renders
a
+# separate, labelled section per non-empty group with its own remediation text.
+ERROR_NO_QUERY_CONTEXT = "no-query-context"
+ERROR_GENERAL = "general-exception"
+
+
+def _fmt(dt: datetime) -> str:
+ return dt.strftime(_DATETIME_FORMAT)
+
+
+def _humanize_ttl(seconds: int) -> str:
+ """Render a TTL as a human-readable, pluralized, translatable duration.
+
+ Whole hours read as "24 hours"; sub-hour and non-hour values keep their
+ minutes (e.g. "1 hour 30 minutes", "15 minutes") so the stated lifetime
+ always matches the real pre-signed URL expiration.
+ """
+ hours, remainder = divmod(seconds, 3600)
+ parts: list[str] = []
+ if hours:
+ parts.append(ngettext("%(num)d hour", "%(num)d hours", hours))
+ if minutes := remainder // 60:
+ parts.append(ngettext("%(num)d minute", "%(num)d minutes", minutes))
+ if not parts:
+ parts.append(ngettext("%(num)d second", "%(num)d seconds", seconds))
+ return " ".join(parts)
+
+
+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 prefix + __(
+ "Your dashboard export is ready: %(title)s", title=dashboard_title
+ )
+ return prefix + __(
+ "Your dashboard export could not be completed: %(title)s",
+ title=dashboard_title,
+ )
+
+
+def _errored_section(errored: dict[str, list[str]]) -> str:
+ """Render one labelled, translated sub-list per non-empty error group.
+
+ ``errored`` maps a reason key (see the ``ERROR_*`` constants) to the labels
+ of the charts that were omitted for that reason. Known reasons are rendered
+ first, in a stable order, each with its own remediation text; any unknown
+ reason key falls back to a generic message so nothing is silently dropped.
+ """
+ if not errored:
+ return ""
+ notes = {
Review Comment:
**Suggestion:** Add an explicit type annotation for this dictionary
assignment so the local collection type is declared. [custom_rule]
**Severity Level:** Minor ๐งน
<details>
<summary><b>Why it matters? โญ </b></summary>
The custom rule requires type hints on relevant variables that can be
annotated. This local dictionary is assigned without an explicit type
annotation, so the suggestion identifies a real rule violation.
</details>
<details>
<summary><b>Rule source ๐ </b></summary>
.cursor/rules/dev-standard.mdc (line 28)
</details>
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=ca99a9bf390944d587d963830cd2202a&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
[](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=ca99a9bf390944d587d963830cd2202a&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:** 94:94
**Comment:**
*Custom Rule: Add an explicit type annotation for this dictionary
assignment so the local collection type is declared.
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=1a84d23dfde52e434c20b532c3a62ebfc0942b99d414de9f003d9f509e63059c&reaction=like'>๐</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41133&comment_hash=1a84d23dfde52e434c20b532c3a62ebfc0942b99d414de9f003d9f509e63059c&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]