fix: Skip export attachments with malformed key (#12470)

Attachments whose key ends in a trailing slash have no filename
component and cause yazl to throw, aborting the entire export. Skip
them with a warning and continue the export instead.

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
Tom Moor
2026-05-26 19:57:36 -04:00
committed by GitHub
parent 03950af3b7
commit 15213bbeb0
@@ -70,6 +70,17 @@ export default abstract class ExportDocumentTreeTask extends ExportTask {
key: attachment.key,
});
// Skip attachments with a malformed key that has no filename component,
// as yazl rejects entries whose path ends with a slash.
if (!attachment.key || attachment.key.endsWith("/")) {
Logger.warn(`Skipping attachment with invalid key`, {
attachmentId: attachment.id,
teamId: attachment.teamId,
key: attachment.key,
});
continue;
}
const dir = path.dirname(pathInZip);
let buffer: Buffer;
try {