Don't raise when a layout is set for only one of html/text - #65
Open
pcbeingused333 wants to merge 1 commit into
Open
pcbeingused333 wants to merge 1 commit into
pcbeingused333 wants to merge 1 commit into
Conversation
`Layouts#layouts` maps `[:html, :text]` through `to_h { ... }` and `next`s
past a format that has no layout. A `next` inside a `to_h` block yields
`nil`, so `to_h` raises `TypeError: wrong element type NilClass`, and the
email blows up in its constructor.
Every `layout` example in the README sets a single format
(`layout text:`, `layout html:`), so this is the common case, not an edge
one. `filter_map { ... }.to_h` drops the missing format instead.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GtYgwYNfJ3wHrw9xrooVoB
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The bug
Layouts#layoutsmaps[:html, :text]throughto_handnexts past a format with no layout:A
nextinside ato_hblock yieldsnil, andto_hexpects every block result to be a 2-element array, so it raises. The email fails in its constructor.Every
layoutexample in the README sets a single format:so this is the normal case.
The fix
filter_map { ... }.to_h— drop the missing format before building the hash. The wrap side (Options#wrap) already skips a missing format, so only the build path needed the guard.Tests
Added
test_html_only_layoutandtest_text_only_layout(with fixtures). Both raiseTypeErroronmainand pass with the fix.bundle exec rakeandbundle exec standardrbare green (161 runs, 0 failures).🤖 Generated with Claude Code