Skip to content

fix(emails): send attachment content type as content_type - #118

Merged
AntoniosBarotsis merged 2 commits into
resend:mainfrom
RaphaelFakhri:fix/attachment-content-type-key
Oct 13, 2026
Merged

AntoniosBarotsis merged 2 commits into
resend:mainfrom
RaphaelFakhri:fix/attachment-content-type-key

Conversation

@RaphaelFakhri

@RaphaelFakhri RaphaelFakhri commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Summary

CreateAttachment renames its content_type field to contentType when it serializes. The send email endpoint reads the attachment content type from content_type, as the API reference and the other SDKs do, so a content type set with with_content_type never reaches the API and the API derives the type from the filename instead.

For example, an attachment built with .with_filename("invoice").with_content_type("application/pdf") currently serializes as {"path":"...","filename":"invoice","contentType":"application/pdf"}.

The Node SDK fixed the same casing in resend/resend-node#391. This change drops the rename so the field serializes as content_type.

Changes

  • src/emails.rs: remove rename = "contentType" from CreateAttachment::content_type, and add a unit test that checks the serialized key.
  • CHANGELOG.md: add an Unreleased entry under Fixed.

Testing

  • cargo test --lib attachment_content_type fails without the fix (content_type is missing from the JSON) and passes with it, with and without --features blocking.
  • cargo fmt --check and cargo clippy --all-targets (with and without --features blocking) report nothing.

Summary by cubic

Fixes attachment content type serialization so with_content_type values reach the API instead of being ignored.

CreateAttachment previously renamed the field to contentType during serialization, but the send email endpoint expects content_type. The API was deriving the type from the filename instead. This change strips the rename, adds a unit test verifying the serialized key, and updates test assertions to satisfy clippy.

Written for commit 601580e. Summary will update on new commits.

View guided diff

@github-actions github-actions Bot added the linear-synced PR has been synced to Linear label Oct 11, 2026
commit 548f4de
Author: Antonios Barotsis <a.barotsis@student.tudelft.nl>
Date:   Tue Oct 13 20:53:46 2026 +0200

    Fix lints
@AntoniosBarotsis

Copy link
Copy Markdown
Collaborator

LGTM, thanks for the heads up and apologies for the delay, I've been busy the last few days. I'll talk to the team and make sure this is how it should function before releasing but that shouldn't take long (probably expect a release tomorrow at the latest).

@AntoniosBarotsis
AntoniosBarotsis merged commit 122fac8 into resend:main Oct 13, 2026
1 check passed
AntoniosBarotsis added a commit that referenced this pull request Oct 16, 2026
commit 122fac8
Author: Raphael Fakhri <153192858+RaphaelFakhri@users.noreply.github.com>
Date:   Tue Oct 13 21:57:44 2026 +0300

    fix(emails): send attachment content type as content_type (#118)

    * fix(emails): send attachment content type as content_type

    * Squashed commit of the following:

    commit 548f4de
    Author: Antonios Barotsis <a.barotsis@student.tudelft.nl>
    Date:   Tue Oct 13 20:53:46 2026 +0200

        Fix lints

    ---------

    Co-authored-by: Antonios Barotsis <a.barotsis@student.tudelft.nl>

commit 548f4de
Author: Antonios Barotsis <a.barotsis@student.tudelft.nl>
Date:   Tue Oct 13 20:53:46 2026 +0200

    Fix lints
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

linear-synced PR has been synced to Linear

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants