codeant-ai-for-open-source[bot] commented on code in PR #44391:
URL: https://github.com/apache/superset/pull/44391#discussion_r4053829909
##########
superset/dashboards/api.py:
##########
@@ -1627,8 +1631,9 @@ def export(self, **kwargs: Any) -> Response:
for file_name, file_content in ExportDashboardsCommand(
requested_ids
).run():
- with bundle.open(f"{root}/{file_name}", "w") as fp:
- fp.write(file_content().encode())
+ write_zip_entry(
+ bundle, f"{root}/{file_name}", file_content().encode()
+ )
Review Comment:
**Suggestion:** `write_zip_entry` uses the host wall clock directly; dates
before 1980 or beyond ZIPโs DOS range make serialization raise, so this
endpoint returns an error instead of an archive.
**Assessment:** ๐ `Major` ยท ๐ `Occurrence: Rarely` ยท ๐ท๏ธ `Possible bug`
[](https://docs.codeant.ai/cli/resolve-pr-comments-skill)
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=f248fe9b0a694ec1bb72040ccb7f4573&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=f248fe9b0a694ec1bb72040ccb7f4573&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
<details>
<summary><b>Prompt for AI Agent ๐ค </b></summary>
```mdx
This is a comment left during a code review.
**Path:** superset/dashboards/api.py
**Line:** 1634:1636
**Comment:**
*Possible Bug: `write_zip_entry` uses the host wall clock directly;
dates before 1980 or beyond ZIPโs DOS range make serialization raise, so this
endpoint returns an error instead of an archive.
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%2F44391&comment_hash=9209e40ba965750be87f684e74582b4c1cd6a8250bdcc06586ad0d16ca229434&reaction=like'>๐</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F44391&comment_hash=9209e40ba965750be87f684e74582b4c1cd6a8250bdcc06586ad0d16ca229434&reaction=dislike'>๐</a>
##########
superset/databases/api.py:
##########
@@ -1565,8 +1566,9 @@ def export(self, **kwargs: Any) -> Response:
for file_name, file_content in ExportDatabasesCommand(
requested_ids
).run():
- with bundle.open(f"{root}/{file_name}", "w") as fp:
- fp.write(file_content().encode())
+ write_zip_entry(
+ bundle, f"{root}/{file_name}", file_content().encode()
+ )
Review Comment:
**Suggestion:** Replacing `ZipFile.open(..., "w")` with `write_zip_entry`
omits the formerโs `0o600` external attributes, changing exported file
permissions when archives are extracted on Unix.
**Assessment:** ๐ `Major` ยท ๐ `Occurrence: Sometimes` ยท ๐ท๏ธ `Api mismatch`
[](https://docs.codeant.ai/cli/resolve-pr-comments-skill)
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=d684e546048d4f239ff0814261442373&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=d684e546048d4f239ff0814261442373&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
<details>
<summary><b>Prompt for AI Agent ๐ค </b></summary>
```mdx
This is a comment left during a code review.
**Path:** superset/databases/api.py
**Line:** 1569:1571
**Comment:**
*Api Mismatch: Replacing `ZipFile.open(..., "w")` with
`write_zip_entry` omits the formerโs `0o600` external attributes, changing
exported file permissions when archives are extracted on Unix.
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%2F44391&comment_hash=dca56062d8711a4d9a9a76113e2842946eb8965e673d636e97f662db1b4eb31c&reaction=like'>๐</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F44391&comment_hash=dca56062d8711a4d9a9a76113e2842946eb8965e673d636e97f662db1b4eb31c&reaction=dislike'>๐</a>
##########
superset/utils/core.py:
##########
@@ -2220,12 +2220,31 @@ def apply_max_row_limit(
return max_limit
+def write_zip_entry(bundle: ZipFile, filename: str, contents: bytes) -> None:
+ """Add a file to an open ZIP bundle, stamped with the current local time.
+
+ ``ZipFile.open(name, "w")`` falls back to the 1980-01-01 DOS epoch, which
+ extractors surface as a bogus (Windows Explorer) or empty (7-Zip)
+ modification date on every extracted file. Passing an explicit ``ZipInfo``
+ gives the entry the time the export was generated instead.
+ """
+ info = ZipInfo(filename=filename, date_time=datetime.now().timetuple()[:6])
Review Comment:
**Suggestion:** `datetime.now()` can produce a year outside ZIP's DOS
timestamp range, causing `ZipInfo` or archive writing to raise and fail the
entire export.
**Assessment:** ๐ `Major` ยท ๐ `Occurrence: Rarely` ยท ๐ท๏ธ `Possible bug`
[](https://docs.codeant.ai/cli/resolve-pr-comments-skill)
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=3241c4381c544e7aa858f76da81c64cf&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=3241c4381c544e7aa858f76da81c64cf&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
<details>
<summary><b>Prompt for AI Agent ๐ค </b></summary>
```mdx
This is a comment left during a code review.
**Path:** superset/utils/core.py
**Line:** 2231:2231
**Comment:**
*Possible Bug: `datetime.now()` can produce a year outside ZIP's DOS
timestamp range, causing `ZipInfo` or archive writing to raise and fail the
entire export.
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%2F44391&comment_hash=5ec0617ed6889e013066df140581cf2bb9a839ec7d0999e887960550484c4797&reaction=like'>๐</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F44391&comment_hash=5ec0617ed6889e013066df140581cf2bb9a839ec7d0999e887960550484c4797&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]