• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

ruby-grape / grape / 26719391341

31 May 2026 05:25PM UTC coverage: 96.865% (+0.004%) from 96.861%
26719391341

Pull #2751

github

ericproulx
Skip absent optional steps when composing structured error messages

`Grape::Exceptions::Base#compose_message` looped over every entry in
`MESSAGE_STEPS` (problem, summary, resolution) and translated each one
individually. For an optional step a message does not define — e.g.
`summary` on `invalid_message_body` — `Grape::Util::Translation#translate`
falls back to returning the scoped key path as a string. That string is
non-blank, so it passed the `detail.present?` guard and leaked verbatim:

    Summary:
      grape.errors.messages.invalid_message_body.summary

Gate each step on whether the already-resolved message hash defines it.
The resolved hash reflects the :en fallback, so locale fallback for
present steps is preserved, and the existing key-path behaviour for a
fully-unresolvable top-level message is untouched.

Fixes #2748.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Pull Request #2751: Skip absent optional steps when composing structured error messages

1105 of 1195 branches covered (92.47%)

Branch coverage included in aggregate %.

3530 of 3590 relevant lines covered (98.33%)

23267.83 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

96.15
/lib/grape/exceptions/validation_errors.rb


Source Not Available

STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc