You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(uploads): attach compiled binary for AI-generated docs, not source (#5266)
* fix(uploads): attach compiled binary for AI-generated docs, not source
AI-generated documents (pdf/docx/pptx/xlsx) created in Chat are stored as
their generation source, with the rendered binary in a separate
content-addressed artifact store. Read/preview paths swap in the binary, but
attachment/upload/provider paths downloaded the raw source — so a generated
PDF emailed via Gmail (and 30+ other tools) arrived as the generator script
renamed .pdf.
- Add shared resolveServableDocBytes resolver + downloadServableFileFromStorage
wrapper; the file-serve route now delegates to the same resolver so the two
paths resolve identically.
- Migrate ~34 attachment/upload/parse tool routes + the LLM provider attachment
path to the servable download; media-only tools and source-editing paths keep
the raw download intentionally.
- Surface a retryable 409 (shared docNotReadyResponse) when a doc artifact is
still compiling instead of shipping source.
* fix(uploads): return retryable 409 for not-ready docs in slack/teams sends
The slack send-message and teams write_channel/write_chat routes call
download helpers that can throw DocCompileUserError while a generated doc is
still compiling. Map it to the shared docNotReadyResponse 409 (matching the
other migrated tool routes) instead of a generic 500. The provider attachment
path is internal LLM execution (no HTTP response), so it intentionally
propagates the typed error.
* fix(uploads): not-ready 409 for uptimerobot, real MIME for non-doc, xlsx tests
Address review findings:
- uptimerobot create-psp/update-psp now map DocCompileUserError to the shared
409 (Greptile + Cursor flagged the gap alongside slack/teams).
- downloadServableFileFromStorage returns the extension-derived MIME
(getMimeTypeFromExtension) for non-doc files instead of an empty string when
userFile.type is unset.
- Add resolveServableDocBytes tests for the three xlsx branches (binary ZIP
passthrough, not-ready throw under E2B+beta, no-workspaceId raw passthrough).
* fix(uploads): enforce attachment size limits on resolved bytes
Size limits were checked against userFile.size (source metadata) before
resolution, but a generated doc resolves to a larger compiled binary — so a
small-source doc could pass the pre-check yet exceed the service limit. Add a
post-resolution check on the actual resolved bytes (mirroring docusign/vanta)
across gmail send/draft/edit-draft, smtp, outlook send/draft, telegram, sftp,
and teams; the cheap source pre-check stays as an early reject.
* chore(uploads): drop extraneous inline comments from servable-file changes
* fix(sftp): enforce 100MB cap on cumulative resolved bytes, not per-file
The SFTP batch upload checked each resolved file against the 100MB cap
individually, so multiple resolved attachments could each pass while their
combined size exceeded the limit. Accumulate resolved bytes across the loop
and reject once the running total exceeds the cap.
* fix(sendgrid): reject attachments exceeding SendGrid's 30MB limit on resolved bytes
SendGrid had no attachment-size guard, so a generated doc resolving to a large
compiled binary could be sent and fail opaquely at the API. Add a post-resolution
total-size check (30MB, SendGrid's documented message limit) matching the
gmail/smtp/outlook routes.
0 commit comments