Skip to content

Missing summary translation leaks raw i18n key into error messages (3.2.1) #2748

@dcasillano

Description

@dcasillano

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.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions