Fix NameError in Mailgun and Mailjet on Ruby 3.4 - #57
Merged
eelcoj merged 1 commit intoAug 31, 2026
Merged
Conversation
Both providers called `Base64.strict_encode64` in `default_headers`
without requiring `base64`. Ruby 3.4 moved `base64` out of the default
gems, so the constant is undefined and every delivery raises NameError.
Since the gemspec already requires Ruby >= 3.4, this affects every
supported version.
Encode with `Array#pack("m0")` instead of requiring `base64`. It is what
`strict_encode64` uses internally and produces identical output, so the
fix adds no new dependency to the gemspec.
Adds test coverage for both providers, including the authentication
headers that reproduce the bug.
Fixes Rails-Designer#56
eelcoj
force-pushed
the
fix-base64-mailgun-mailjet
branch
from
August 31, 2026 11:18
0cd30ea to
9e362b0
Compare
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.
Mailgun#default_headersandMailjet#default_headersboth callBase64.strict_encode64without requiringbase64. Ruby 3.4 movedbase64out of the default gems, so the constant is undefined and every delivery through either provider raisesNameError:The gemspec already sets
required_ruby_version = ">= 3.4.0", so this affects every supported Ruby version.The fix
Encode with
Array#pack("m0")rather than addingrequire "base64".strict_encode64is implemented on top of the same pack directive, and the output is byte-identical (verified across ASCII, UTF-8, empty string, and long input). Using it directly avoids adding a bundled-gem dependency to the gemspec for two lines of code.Tests
Adds
mailgun_test.rbandmailjet_test.rb— 11 tests covering body formatting, endpoint construction, thedomainrequirement,reply_toomission, and the auth headers that reproduce the bug.Both auth tests fail on
mainwith the reportedNameErrorand pass with this change. Full suite: 111 runs, 202 assertions, 0 failures, 0 errors.standardrbreports no offenses.The expected header values are written as base64 literals rather than computed with
pack, so the tests do not validate the implementation against itself.Fixes #56