Skip to content

fix(platform): send an email that carries only an attachment - #3514

Merged
yannickmonney merged 1 commit into
mainfrom
fix/attachment-only-email-reply
Sep 27, 2026
Merged

yannickmonney merged 1 commit into
mainfrom
fix/attachment-only-email-reply

Conversation

@yannickmonney

@yannickmonney yannickmonney commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

Summary

The Inbox composer offers Send when a file is attached and nothing is typed, and hands the send an empty body. Both the reply path and the compose path then refused that body:

  • the adapter read '' as a missing argument;
  • both server doors required content to be at least one character.

So the person always read "Couldn't send message". This change accepts an empty body when at least one file goes with it, and still refuses a send that carries neither. The adapter, the two doors and the send service all apply one shared rule.

Task: TALE-33 (triage T10, P2).

What changed

  • lib/shared/conversations/outbound-content.ts: adds hasBodyOrAttachments({content, attachments}). Only '' counts as an empty body, so every body the doors accepted before, whitespace included, still passes.
  • Adapter (app/lib/backend/conversations.ts): reply and compose read the body through emailContentArg. An empty body with files is sent. An empty body without files still throws before any request is made.
  • Doors (backend/domains/conversations/routes.ts): /:id/reply and /compose now take content: z.string().max(200_000) with .refine(hasBodyOrAttachments). A request with neither a body nor a file still gets 400 invalid body before anything is read.
  • Service (backend/domains/conversations/send.ts): replyToConversation and composeEmailConversation refuse a send with neither (reply_content_required / compose_content_required, 400) before their first read. Until now, a caller that went around the door could queue an empty email.
  • Manual layer: adds box CONV-F32 and its 🔶 row in reference/automation.md.

Why accept it rather than disable Send

Everything below these checks already carries an email that has only attachments:

  • The API lane (queueApiReply) skips minBodyChars when files go with the reply.
  • The send job takes body: z.string(), and a retry re-sends the stored body, content type and files.
  • The gmail, outlook and imap-smtp send operations require only to and subject. Gmail and Outlook send input.body || ''; the imap-smtp native parses text as optional and sends a text-less plain message.
  • app.conversation_messages.content is only NOT NULL, so '' is a valid row.

The compose pane uses the same editor and failed the same way, so it is fixed here too.

Checklist

  • bun run check: not run as one command. The sandbox's 4 GiB memory cap rules out the whole-workspace tsc and the full suites, so each part was run on the touched scope instead (see the test plan). CI runs the full gate.
  • bun run lint:sast passes.
  • Translations: N/A. No key was added, changed or removed. The two new service messages are developer-facing, like compose_subject_required, and the UI cannot reach them because the adapter and the door refuse first.
  • Docs: N/A. No page under docs/*/platform/ describes the reply box or what a send must carry. The fix makes the Send button the UI already offers work.
  • README.md / README.de.md / README.fr.md: N/A.

Test plan

Regression tests. With origin/main's adapter, doors and service swapped back in, six server-project tests and the browser test below fail; here they pass.

  • app/lib/backend/conversations.test.ts: the reply and compose adapters send content: '' beside files. '' with no attachments or an empty list, or a body that is not a string, still throws and sends nothing.
  • backend/domains/conversations/routes.test.ts: both doors answer 201 for an attachment-only body, and the attachment ownership check still runs. A request with neither answers 400 before any read.
  • backend/domains/conversations/send.test.ts: the service refuses a send with neither before any statement (on main it queued an empty email). An attachment-only reply or compose queues an empty Text part plus the files, and an API thread gets body: '' plus the files.
  • message-editor.browser.test.tsx (real Chromium): attach a file and type nothing, and Send message is enabled. Pressing it runs the real reply mutation and adapter, which POST /api/app/conversations/c1/reply with {content: '', attachments}, and no toast appears. Against main's adapter it fails with Missing content for adapted write and then "Failed to send message".

Characterization tests: message-editor.test.tsx (the editor hands over ('', [file], undefined), and nothing is sent with neither text nor a file) and outbound-content.test.ts (the predicate).

Run in the sandbox, on top of 768f4f183:

  • Server project over backend/domains/conversations/, backend/jobs/task-list.send-message.test.ts, lib/shared/conversations/ and the adapter test: 27 files, 252 tests passed.
  • test:ui over app/features/conversations/: 24 files, 200 tests passed.
  • test:browser on message-editor.browser.test.tsx: 4 of 4 passed, including the two height tests main added to the same file.
  • oxfmt --check on every changed file: clean.
  • oxlint --type-aware --type-check on the eight changed files the platform lints: clean. A planted type error was reported first, so the silent pass is real. lib/shared is outside the platform lint, so the predicate and its test were compiled on their own with tsc --strict --exactOptionalPropertyTypes --noUncheckedIndexedAccess: clean.
  • bun run lint:sast, bun run lint:manual, and check-guide.ts on conversations.md: clean.

Not run: backend:integration. It needs Postgres, this sandbox has no Docker daemon, and no CI workflow runs it. The change adds no SQL, and both of the integration check's replyToConversation calls carry a body, so the new guard cannot trip them. The whole-platform suites ran in CI.

Manual: CONV-F32 covers real delivery through a mailbox, the message bubble after a reload, and compose.

Left open

These are existing gaps, outside this change:

  • Undoing a reply restores only its markdown draft. Attachments never return to the composer, so undoing an attachment-only reply restores nothing.
  • An empty body renders as an empty preview above the attachment list, the same way an inbound email with only attachments does today.
  • The remove (✕) button on an attached-file chip has no accessible name (message-editor/file-attachments-list.tsx).

The Inbox composer offers Send for a file with no text and hands the
send an empty body. The reply and compose adapters read that body as
a missing argument and threw before any request, and both doors
refused it with a content minimum of one character, so the person
read "Couldn't send message" every time.

One predicate in lib/shared/conversations now says what an outbound
email must carry: a body, a file, or both. The two adapters, the
reply and compose doors, replyToConversation and
composeEmailConversation all apply it. An empty body beside files
goes out; a send with neither is still refused before anything is
read, now in the service too, where a caller that skipped the door
could queue an empty email. Every lane below already carried an
empty body. The API lane skips its minimum when files go with the
reply, and gmail, outlook and the imap-smtp native send an empty
text part.

The adapter, door, service and editor tests cover both sides, a
browser test drives the real editor through the reply mutation, and
CONV-F32 keeps real delivery on the manual round.
@yannickmonney
yannickmonney merged commit 30210b5 into main Sep 27, 2026
57 checks passed
@yannickmonney
yannickmonney deleted the fix/attachment-only-email-reply branch September 27, 2026 15:44
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