Skip to content

Allow omitting Subject and From for hosted-template sends (#117)#126

Merged
felipefreitag merged 1 commit into
mainfrom
fix/optional-subject-template
Jul 9, 2026
Merged

Allow omitting Subject and From for hosted-template sends (#117)#126
felipefreitag merged 1 commit into
mainfrom
fix/optional-subject-template

Conversation

@felipefreitag

@felipefreitag felipefreitag commented Jul 9, 2026

Copy link
Copy Markdown
Member

Resolves #117.

Problem

EmailMessage.Subject and EmailMessage.From are non-nullable and lack JsonIgnore, so they are always serialized. When sending a hosted template, the API allows omitting subject/from to use the template's defaults (server validation only requires them when template.id is absent). Today the SDK can't cleanly omit them — sending subject: null risks a validation error.

Fix

Make Subject and From nullable with [JsonIgnore(Condition = WhenWritingNull)], so they're omitted from the payload when unset.

Scope note: #117 names only Subject, but From has the identical problem and a template send needs both omittable, so this includes From too. Happy to split it out if you'd prefer the PR mirror the issue exactly.

No regression for normal sends: a missing subject was already rejected server-side and still is — this only changes null from "subject": null to omitted.

Verification

Build + full suite on .NET 8: 117/117 pass (2 new serialization tests: omitted-when-null, present-when-set).


Summary by cubic

Allows omitting Subject and From when sending a hosted template. This matches the API and uses template defaults instead of sending null values.

  • Bug Fixes
    • Made Subject and From nullable with JsonIgnore(WhenWritingNull) so they’re excluded from JSON when unset; normal sends remain server-validated.
    • Added serialization tests for omit-when-null and include-when-set.

Written for commit b962801. Summary will update on new commits.

Review in cubic

EmailMessage.Subject and From were non-nullable and always serialized,
so a hosted-template send could not omit them to fall back to the
template's defaults (sending subject: null risks a validation error).
The send API makes subject/from optional when template.id is present.

Make both nullable with JsonIgnore(WhenWritingNull) so they are omitted
when unset. Normal sends are unaffected (a missing subject was already a
server-side error and still is). From is included alongside Subject
because a template send needs both omittable.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

No issues found across 2 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Auto-approved: Makes Subject and From nullable with JsonIgnore(WhenWritingNull) for hosted-template sends. Small, isolated change with tests.

Re-trigger cubic

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.

EmailMessage.Subject cannot be omitted when sending hosted templates

1 participant