MESSAGE_STEPS includes summary as an optional step, but when no summary key
is defined for an error type, Grape::Util::Translation#translate falls back to
returning the dotted key path as a string. Since that string is non-empty, it passes
the detail.present? guard in compose_message and leaks into the output:
Grape::Exceptions::InvalidMessageBody.new('application/json').message
=> "...\nSummary:\n grape.errors.messages.invalid_message_body.summary\n..."
The fallback on line 27 of util/translation.rb should return nil (or be
guarded against in compose_message) so that missing optional steps are silently
skipped rather than included verbatim.
MESSAGE_STEPSincludessummaryas an optional step, but when nosummarykeyis defined for an error type,
Grape::Util::Translation#translatefalls back toreturning the dotted key path as a string. Since that string is non-empty, it passes
the
detail.present?guard incompose_messageand leaks into the output:The fallback on line 27 of
util/translation.rbshould returnnil(or beguarded against in
compose_message) so that missing optional steps are silentlyskipped rather than included verbatim.