codeant-ai-for-open-source[bot] commented on code in PR #43188:
URL: https://github.com/apache/superset/pull/43188#discussion_r3787061978
##########
superset/utils/file.py:
##########
@@ -32,5 +37,13 @@ def sanitize_title(title: str) -> str:
def get_filename(model_name: str, model_id: int, skip_id: bool = False) -> str:
model_name = sanitize_title(model_name)
slug = secure_filename(model_name)
- filename = slug if skip_id else f"{slug}_{model_id}"
- return filename if slug else str(model_id)
+ suffix = "" if skip_id else f"_{model_id}"
+ # The name goes into a ZIP entry that already carries an
+ # `<asset>_export_<timestamp>/<type>/` prefix and a `.yaml` suffix, and the
+ # user's own extraction directory sits in front of all of it. A chart
titled
+ # with a couple of hundred characters therefore produced an entry Windows
+ # refuses to extract, even though the archive itself was written fine. Trim
+ # the slug rather than the id: the id is what keeps two similarly titled
+ # assets from colliding inside one archive.
+ slug = slug[: max(MAX_FILENAME_LENGTH - len(suffix), 0)].rstrip("._-")
Review Comment:
**Suggestion:** Truncating `slug` creates identical filenames for distinct
long titles whenever `skip_id=True`. Export commands use these names for
databases and related datasets, and their `seen` sets silently discard later
entries with the same path, causing assets to be omitted from the archive.
Preserve uniqueness after truncation, for example by adding a deterministic
hash or retaining an identifier for these paths. [logic error]
<details>
<summary><b>Severity Level:</b> Major ⚠️</summary>
```mdx
- ⚠️ Missing YAML files can produce incomplete imports.
```
</details>
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=10a9dde491804a5789b4230c553cf987&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=10a9dde491804a5789b4230c553cf987&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/file.py
**Line:** 48:48
**Comment:**
*Logic Error: Truncating `slug` creates identical filenames for
distinct long titles whenever `skip_id=True`. Export commands use these names
for databases and related datasets, and their `seen` sets silently discard
later entries with the same path, causing assets to be omitted from the
archive. Preserve uniqueness after truncation, for example by adding a
deterministic hash or retaining an identifier for these paths.
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%2F43188&comment_hash=7e673203892a3363b65e8af819aa0adda874c92ffaeeb7ce9f87ae446fa811bd&reaction=like'>👍</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F43188&comment_hash=7e673203892a3363b65e8af819aa0adda874c92ffaeeb7ce9f87ae446fa811bd&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]