Skip to content

fix(files): keep file extensions on extensionless downloads - #7573

Merged
waleedlatif1 merged 2 commits into
stagingfrom
fix/folder-download-zip-extensions
Sep 7, 2026
Merged

fix(files): keep file extensions on extensionless downloads#7573
waleedlatif1 merged 2 commits into
stagingfrom
fix/folder-download-zip-extensions

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

Summary

  • Files whose stored name has no extension (a file renamed to <name> in the Files UI, or a URL fetch whose path ends in a bare download segment) downloaded with no extension, so the saved image could not be opened until one was added by hand
  • Add ensureFileNameExtension and apply it to zip entry paths (internal + v2 bulk download, Chat compress), to createFileResponse for single-file downloads (generalizes the existing Sim-page .html re-append), and to the URL-fetch save path so new files are stored with an extension
  • getExtensionFromMimeType now ignores content-type parameters such as ; charset=utf-8

Follow-ups, out of scope here: the markdown export's embedded-asset zip and the v1/v2 single-file routes build their own Content-Disposition and still emit the extensionless name; the Chat agent's private ensureFileExtension can be consolidated onto the shared helper.

Type of Change

  • Bug fix

Testing

  • Unit tests added for the helper, zip entry paths, createFileResponse, and the URL-fetch naming; affected suites pass
  • bun run lint, bun run check:audits (45 audits), docs-manifest:check, and type-check pass

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel

vercel Bot commented Sep 7, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
docs Skipped Skipped Sep 7, 2026 11:29pm UTC

Request Review

@greptile-apps

greptile-apps Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR preserves MIME-derived extensions when extensionless files are fetched, served individually, or placed into ZIP archives.

  • Adds a shared ensureFileNameExtension helper and parameter-tolerant MIME lookup.
  • Applies the helper across single-file responses, external URL imports, and bulk/archive paths.
  • Adds focused coverage for MIME parameters, duplicate ZIP names, longer extensions, and page names containing punctuation.
  • The previously reported extension-length issue is fixed, and its thread was resolved.

Confidence Score: 5/5

The PR appears safe to merge with no outstanding correctness, security, or repository-rule issues.

The follow-up replaces the capped extension regex with the repository’s existing alphanumeric-extension predicate, preserving long extensions while retaining the intended behavior for punctuation-bearing page names. The previous finding was fully addressed and its thread was resolved.

Important Files Changed

Filename Overview
apps/sim/lib/uploads/utils/file-utils.ts Adds shared MIME-derived extension handling and fixes extension detection without imposing a length cap.
apps/sim/app/api/files/utils.ts Uses the shared helper when deriving single-file response names before secure disposition selection.
apps/sim/lib/uploads/contexts/workspace/fetch-external-url.ts Adds a MIME-derived extension to extensionless URL path names before workspace upload.
apps/sim/lib/uploads/zip-entry-path.ts Adds missing MIME-derived extensions before ZIP-path sanitization and collision handling.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[Stored or fetched filename] --> B{Alphanumeric extension exists?}
  B -- Yes --> C[Preserve filename]
  B -- No --> D[Map content type to extension]
  D --> E[Append mapped extension]
  C --> F[Single-file response or ZIP entry]
  E --> F
Loading

Reviews (2): Last reviewed commit: "fix(files): detect extensions without a ..." | Re-trigger Greptile

Comment thread apps/sim/lib/uploads/utils/file-utils.ts Outdated
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@waleedlatif1 I have started the AI code review. It will take a few minutes to complete.

@waleedlatif1
waleedlatif1 merged commit c762c57 into staging Sep 7, 2026
31 checks passed
@waleedlatif1
waleedlatif1 deleted the fix/folder-download-zip-extensions branch September 7, 2026 23:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant