antiwork/gumroad · error · ArgumentError
Please enter a valid Kindle email address
Error message
Please enter a valid Kindle email address
What it means
Raised as ArgumentError by SendableToKindle#send_to_kindle (app/modules/sendable_to_kindle.rb:12) when the supplied kindle_email does not match KINDLE_EMAIL_REGEX (config/initializers/aws.rb:34). The regex is strict about the domain: the address must end in @kindle.com (case-insensitive), be 3–255 characters, and have no leading/consecutive dots — so a Gmail/Yahoo address fails even though it is a valid email. The method then enqueues CustomerMailer.send_to_kindle on the critical queue, optionally passing the url_redirect whose id locates the buyer-specific stamped PDF.
Source
Thrown at app/modules/sendable_to_kindle.rb:12
# frozen_string_literal: true
module SendableToKindle
extend ActiveSupport::Concern
included do
# `url_redirect` provides the purchase context needed to locate the
# buyer-specific stamped copy of a stamp-enabled PDF. Without it the
# original (un-watermarked) file would be emailed, bypassing the
# seller's PDF stamping setting.
def send_to_kindle(kindle_email, url_redirect: nil)
raise ArgumentError, "Please enter a valid Kindle email address" unless kindle_email.match(KINDLE_EMAIL_REGEX)
CustomerMailer.send_to_kindle(kindle_email, id, url_redirect&.id).deliver_later(queue: "critical")
end
end
end
View on GitHub (pinned to afeacbd394)
Solutions
- Instruct the user to enter their @kindle.com address (Kindle device settings → Send-to-Kindle email); validate the same pattern client-side before submitting.
- Strip whitespace and downcase before validating.
- Rescue ArgumentError around send_to_kindle and re-prompt for a corrected address instead of a 500.
Example fix
# before
purchase.send_to_kindle(params[:email]) # ArgumentError for non-@kindle.com
# after
email = params[:email].to_s.strip.downcase
unless email.match?(KINDLE_EMAIL_REGEX)
return { error: "Please enter a valid Kindle email address (must end in @kindle.com)." }
end
purchase.send_to_kindle(email) Defensive patterns
Strategy: validation
Validate before calling
email = kindle_email.to_s.strip.downcase
return { error: 'Enter your @kindle.com address.' } unless email.match?(KINDLE_EMAIL_REGEX) Try / catch
begin
purchase.send_to_kindle(email, url_redirect:)
rescue ArgumentError => e
render json: { message: e.message }, status: :unprocessable_entity # re-prompt for a @kindle.com address
end Prevention
- Validate the @kindle.com suffix client-side — a valid generic email is not enough for this API.
- Strip and downcase input before matching; reject consecutive/leading dots and strings over 255 chars.
- Tell users where to find the address: Kindle device settings → Send-to-Kindle email.
When it happens
Trigger: Calling purchase.send_to_kindle(email) / library-item send-to-Kindle with any address not ending in @kindle.com — regular email addresses, typos like 'user@kindle.co', empty strings, or addresses with consecutive dots. User.kindle_email is validated against the same regex on save.
Common situations: Buyers entering their normal email instead of the @kindle.com address from their Kindle device settings; whitespace or a second @; front-end accepting any RFC-5322 address without the domain restriction.
Related errors
- Something went wrong.
- This commission has already been completed, so its files can
- This commission's deposit is no longer in a completable stat
- Attach at least one file before completing this commission.
- You have to confirm your email address before you can do tha
AI-assisted analysis of antiwork/gumroad@afeacbd394 (2026-08-21).
Data as JSON: /api/errors/548c7eb0b7feac1e.
Report an issue: GitHub.