Skip to content

fix(files): skip zip and return plain .md when no embedded images#4498

Merged
waleedlatif1 merged 3 commits intostagingfrom
fix/download
May 7, 2026
Merged

fix(files): skip zip and return plain .md when no embedded images#4498
waleedlatif1 merged 3 commits intostagingfrom
fix/download

Conversation

@waleedlatif1
Copy link
Copy Markdown
Collaborator

Summary

  • MD files with no embedded image references now download as plain .md instead of a .zip
  • ZIP is only produced when the file contains resolved /api/files/view/ image assets

Type of Change

  • Bug fix

Testing

Tested manually

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
Copy link
Copy Markdown

vercel Bot commented May 7, 2026

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

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped May 7, 2026 9:14pm

Request Review

@cursor
Copy link
Copy Markdown

cursor Bot commented May 7, 2026

PR Summary

Low Risk
Low risk behavior change isolated to the file export route; main impact is clients that previously always expected a ZIP for markdown exports.

Overview
Updates GET /api/files/export/[id] so markdown files without embedded /api/files/view/… image references are returned directly as text/markdown with an attachment filename, instead of generating a ZIP.

ZIP generation is now only used when one or more embedded image assets are detected (log message adjusted accordingly).

Reviewed by Cursor Bugbot for commit 26edc0c. Configure here.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 7, 2026

Greptile Summary

This PR fixes markdown export so files with no embedded /api/files/view/ image references are returned as plain .md downloads instead of a single-file ZIP. The imageIds.length === 0 guard correctly targets only the no-image-references case.

  • An early return is inserted after extracting imageIds: if empty, the raw markdown is serialised to UTF-8 and returned with text/markdown content-type and correct Content-Disposition.
  • The ZIP path is unchanged; it is only reached when the markdown contains at least one resolved image reference.

Confidence Score: 5/5

Safe to merge — the change is narrowly scoped and does not alter the ZIP path.

The early-return branch is well-isolated: it fires only when no image IDs are extracted, uses the same safeFilename helper already in use throughout the file, and correctly encodes the markdown to UTF-8 before sending. The more precise imageIds.length === 0 guard prevents the branch from masking failed image fetches. No existing code paths are affected.

No files require special attention.

Important Files Changed

Filename Overview
apps/sim/app/api/files/export/[id]/route.ts Adds an early return for markdown files with no embedded image references, serving plain .md directly instead of wrapping in a ZIP; uses the precise imageIds.length === 0 guard per the previous review thread.

Reviews (3): Last reviewed commit: "fix(files): move imageIds.length guard b..." | Re-trigger Greptile

Comment thread apps/sim/app/api/files/export/[id]/route.ts Outdated
Comment thread apps/sim/app/api/files/export/[id]/route.ts Outdated
@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@cursor review

Comment thread apps/sim/app/api/files/export/[id]/route.ts Outdated
@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@cursor review

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 26edc0c. Configure here.

@waleedlatif1 waleedlatif1 merged commit f708462 into staging May 7, 2026
10 checks passed
@waleedlatif1 waleedlatif1 deleted the fix/download branch May 7, 2026 21:23
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