Skip to content

fix(ext.smtp): unnamed attachments and encoded X-headers - #824

Merged
derks merged 1 commit into
mainfrom
fix/ext-smtp-819-820
Oct 20, 2026
Merged

derks merged 1 commit into
mainfrom
fix/ext-smtp-819-820

Conversation

@derks

@derks derks commented Oct 20, 2026 •

Copy link
Copy Markdown
Member

Summary

Fixes two TypeErrors in ext.smtp reported by @TomFreudenberg.

Test cleanup: the PNG fixture code repeated in three tests is now a _make_png() helper.

Follow-ups: #821 (quote Content-Disposition filename), #822 (re-enable X-header assertion), #823 (opt-in files_basename).

Test plan

  • New tests: (None, path) tuple, dict with cid and no name
  • Base64 and QP encoding tests send an X-header and assert the encoded and decoded value in Mailpit
  • tests/ext/test_ext_smtp.py: 28 passed, ext_smtp.py at 100% coverage
  • make comply (ruff + mypy) clean

Closes #819
Closes #820

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Fixed errors when sending attachments without alternate filenames.
    • Fixed errors when sending custom X-headers with header encoding enabled.
    • Improved fallback handling for attachment filenames and inline images without names, including use of the file’s basename when available.
    • Corrected custom header encoding for Base64 and quoted-printable messages, ensuring encoded headers can be sent and read correctly.
    • Added support for attachments provided without optional filename values.

@coderabbitai

coderabbitai Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 84ed4259-8efb-414a-bc32-05e05072c516
📥 Commits

Reviewing files that changed from the base of the PR and between edb0b2c and 73e5a19.

📒 Files selected for processing: 1
  • CHANGELOG.md
🚧 Files skipped from review as they are similar to previous changes: 1
  • CHANGELOG.md

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 0 remain after this review.

📝 Walkthrough

The SMTP extension now accepts encoded X-headers and handles attachments without alternate names. Tests cover encoded headers, basename fallback, and inline image metadata. The changelog records both fixes.

Changes: SMTP fixes

Layer / File(s) Summary
Encoded X-header assignment
cement/ext/ext_smtp.py, tests/ext/test_ext_smtp.py, CHANGELOG.md
X-headers are assigned through the message mapping. Base64 and quoted-printable tests verify encoded and decoded header values. The changelog records the X-header fix.
Attachments without alternate names
cement/ext/ext_smtp.py, tests/ext/test_ext_smtp.py
Tuple and dictionary attachments tolerate missing names and fall back to the path basename. Tests cover unnamed file tuples and inline image dictionaries.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to 73e5a

No concrete issue remains identified that should block merging.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 21.43% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 14 functions across 2 files. (1 skipped: … Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely identifies both main fixes: unnamed SMTP attachments and encoded X-headers.
Linked Issues check Passed The supplied PR evidence supports both active linked issues. For #819, tuple and dictionary attachment handling no longer calls os.path.basename() on a missing name, and tests verify basename fallback…
Out of Scope Changes check Passed The changes stay within #819 and #820. The _make_png() helper removes repeated test setup, and the added tests verify the required attachment and X-header behavior. The changelog records these fixes. …
Full details: Linked Issues check

Explanation

The supplied PR evidence supports both active linked issues. For #819, tuple and dictionary attachment handling no longer calls os.path.basename() on a missing name, and tests verify basename fallback for (None, path) and a dictionary without name. For #820, _set_headers assigns X-headers with msg[item], which supports Header values, and the base64 and quoted-printable tests verify encoded and decoded header values.

Full details: Out of Scope Changes check

Explanation

The changes stay within #819 and #820. The _make_png() helper removes repeated test setup, and the added tests verify the required attachment and X-header behavior. The changelog records these fixes. No unrelated implementation change is shown in the supplied PR evidence.

Full details: Docstring Coverage

Explanation

Docstring coverage is 21.43% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 14 functions across 2 files. (1 skipped: 1 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Closes #819, closes #820.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@derks
derks force-pushed the fix/ext-smtp-819-820 branch from edb0b2c to 73e5a19 Compare October 20, 2026 19:40
@derks
derks merged commit a3b96e3 into main Oct 20, 2026
14 checks passed
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.

ext.smtp: X-headers raise TypeError when header_encoding is set ext.smtp: attachment without alternative name raises TypeError

1 participant