Skip to content

Treat a missing email subject as empty - #136

Merged
Jamesking56 merged 1 commit into
captbaritone:masterfrom
wazum:bugfix/135-null-subject
Oct 1, 2026
Merged

Jamesking56 merged 1 commit into
captbaritone:masterfrom
wazum:bugfix/135-null-subject

Conversation

@wazum

@wazum wazum commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

Resolves: #135

MailCatcher returns "subject": null for emails without a Subject header. Email::getSubject() is declared : string, so it threw a TypeError. As a result, seeInLastEmailSubject, dontSeeInLastEmailSubject and their ...To variants errored instead of acting as assertions.

getSubject() now returns '' for a missing subject. The constructor still accepts null, so nothing changes for callers.

Tests

  • EmailTest::testMissingSubjectIsEmpty
  • MailCatcherTest::testDontSeeInLastEmailSubjectWithoutSubject: passes
  • MailCatcherTest::testSeeInLastEmailSubjectWithoutSubjectFails: fails as an assertion, not with a TypeError

All three failed with the TypeError before the fix. I confirmed against a real MailCatcher that an email sent over SMTP without a Subject header comes back with "subject": null.

MailCatcher returns "subject": null for emails without a Subject header,
which made Email::getSubject() throw a TypeError and every subject
assertion error out instead of passing or failing.

Resolves: captbaritone#135
@github-actions
github-actions Bot requested a review from Jamesking56 October 1, 2026 09:17
@github-actions github-actions Bot added the bug label Oct 1, 2026

@Jamesking56 Jamesking56 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Reviewed all three changed files. The null-to-empty fallback fixes issue #135 through the shared subject getter and preserves existing subjects. Unit tests pass locally (20 tests, 37 assertions), and all six CI test configurations pass.

@Jamesking56
Jamesking56 merged commit 37b8b07 into captbaritone:master Oct 1, 2026
9 checks passed
@Jamesking56

Copy link
Copy Markdown
Collaborator

Thanks @wazum

@github-actions

github-actions Bot commented Oct 2, 2026

Copy link
Copy Markdown

Released in 4.1.0.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Subject assertions throw TypeError for emails without a Subject header

2 participants