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

ruby-grape / grape / 32106065653
97%
master: 97%

Build:
Build:
LAST BUILD BRANCH: fix/route-success-failure-readers
DEFAULT BRANCH: master
Ran 18 Aug 2026 06:14AM UTC
Jobs 32
Files 168
Run time 1min
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

18 Aug 2026 06:14AM UTC coverage: 96.978% (-0.006%) from 96.984%
32106065653

Pull #2840

github

ericproulx
Answer 500 when an error response cannot be rendered

Grape::Middleware::Error#call! renders the error response from inside its own
rescue clause, so that clause never covered the rendering. An error formatter
that raised on the payload it was handed took the exception straight out
through every middleware above Grape and into the application server —
`rescue_from :all` did not help, because the failure happened after the
handler had already returned.

A rescue_from handler echoing request-derived bytes was enough to hit it:

    rescue_from(Missing) { |e| error!({ detail: e.message }, 404) }

with an invalid UTF-8 byte in the path, the JSON formatter raised
JSON::GeneratorError and the request died rather than being answered.

Guard the rendering in error_response. On failure, first retry the API's own
format with the framework's InternalServerError, whose message is a static
string and so cannot be what defeated the first attempt; if that fails too — a
formatter broken outright rather than one payload it choked on — answer
without a formatter at all. Both attempts call format_message directly instead
of re-entering error_response, so the fallback cannot recurse. This is the
shape ActionDispatch::ShowExceptions#render_exception already has in Rails,
down to the text/plain last resort.

The guard sits on the rendering rather than around run_rescue_handler on
purpose. Wrapping the handler call too would have swallowed things that must
keep propagating, the deprecation raised when a handler returns a Hash among
them.

Exceptions that no rescue_from matches still propagate unchanged; only
rendering failures are caught.

Swallowing an exception must not make it invisible. Grape put the exception on
env['grape.exception'], but that is a Grape-private key no tracker reads, so a
rendering failure that Sentry used to report as a raised exception would have
become an unremarkable 500. Publish it on env['rack.exception'] as well — the
convention for an exceptio... (continued)
Pull Request #2840: Answer 500 when an error response cannot be rendered

1216 of 1307 branches covered (93.04%)

Branch coverage included in aggregate %.

23 of 23 new or added lines in 3 files covered. (100.0%)

5 existing lines in 1 file now uncovered.

3855 of 3922 relevant lines covered (98.29%)

26873.01 hits per line

Coverage Regressions

Lines Coverage ∆ File
5
94.12
0.22% lib/grape/middleware/error.rb
Jobs
ID Job ID Ran Files Coverage
1 run-3.3-gemfiles/rack_3_2.gemfile - 32106065653.1 18 Aug 2026 06:15AM UTC 167
95.62
GitHub Action Run
2 run-4.0-gemfiles/dry_validation.gemfile - 32106065653.2 18 Aug 2026 06:14AM UTC 167
57.9
GitHub Action Run
3 run-3.3-gemfiles/rails_7_2.gemfile - 32106065653.3 18 Aug 2026 06:14AM UTC 168
95.62
GitHub Action Run
4 run-4.0-gemfiles/rails_7_2.gemfile - 32106065653.4 18 Aug 2026 06:14AM UTC 168
95.62
GitHub Action Run
5 run-3.4-gemfiles/rack_3_2.gemfile - 32106065653.5 18 Aug 2026 06:14AM UTC 167
95.62
GitHub Action Run
6 run-3.4-Gemfile - 32106065653.6 18 Aug 2026 06:14AM UTC 167
95.62
GitHub Action Run
7 run-3.3-gemfiles/rails_8_0.gemfile - 32106065653.7 18 Aug 2026 06:15AM UTC 168
95.62
GitHub Action Run
8 run-4.0-gemfiles/multi_xml_0_8.gemfile - 32106065653.8 18 Aug 2026 06:15AM UTC 167
46.98
GitHub Action Run
9 run-4.0-gemfiles/multi_xml.gemfile - 32106065653.9 18 Aug 2026 06:14AM UTC 167
46.95
GitHub Action Run
10 run-3.4-gemfiles/rack_3_1.gemfile - 32106065653.10 18 Aug 2026 06:14AM UTC 167
95.62
GitHub Action Run
11 run-4.0-gemfiles/multi_json.gemfile - 32106065653.11 18 Aug 2026 06:14AM UTC 167
47.54
GitHub Action Run
12 run-3.3-gemfiles/rack_3_0.gemfile - 32106065653.12 18 Aug 2026 06:14AM UTC 167
95.62
GitHub Action Run
13 run-4.0-gemfiles/hashie.gemfile - 32106065653.13 18 Aug 2026 06:14AM UTC 167
61.84
GitHub Action Run
14 run-3.3-gemfiles/rails_8_1.gemfile - 32106065653.14 18 Aug 2026 06:15AM UTC 168
95.62
GitHub Action Run
15 run-4.0-gemfiles/rails_8_0.gemfile - 32106065653.15 18 Aug 2026 06:15AM UTC 168
95.62
GitHub Action Run
16 run-4.0-gemfiles/rack_3_1.gemfile - 32106065653.16 18 Aug 2026 06:14AM UTC 167
95.62
GitHub Action Run
17 run-3.4-gemfiles/rails_8_1.gemfile - 32106065653.17 18 Aug 2026 06:15AM UTC 168
95.62
GitHub Action Run
18 run-4.0-gemfiles/grape_entity.gemfile - 32106065653.18 18 Aug 2026 06:15AM UTC 167
50.22
GitHub Action Run
19 run-4.0-gemfiles/rack_2_2.gemfile - 32106065653.19 18 Aug 2026 06:14AM UTC 167
95.58
GitHub Action Run
20 run-3.3-Gemfile - 32106065653.20 18 Aug 2026 06:15AM UTC 167
95.62
GitHub Action Run
21 run-4.0-gemfiles/rack_3_2.gemfile - 32106065653.21 18 Aug 2026 06:15AM UTC 167
95.62
GitHub Action Run
22 run-3.4-gemfiles/rails_7_2.gemfile - 32106065653.22 18 Aug 2026 06:15AM UTC 168
95.62
GitHub Action Run
23 run-4.0-gemfiles/rack_3_0.gemfile - 32106065653.23 18 Aug 2026 06:15AM UTC 167
95.62
GitHub Action Run
24 run-4.0-gemfiles/multi_json_1_20.gemfile - 32106065653.24 18 Aug 2026 06:14AM UTC 167
47.58
GitHub Action Run
25 run-3.4-gemfiles/rack_3_0.gemfile - 32106065653.25 18 Aug 2026 06:14AM UTC 167
95.62
GitHub Action Run
26 run-3.3-gemfiles/rack_2_2.gemfile - 32106065653.26 18 Aug 2026 06:14AM UTC 167
95.58
GitHub Action Run
27 run-4.0-gemfiles/grape_swagger.gemfile - 32106065653.27 18 Aug 2026 06:14AM UTC 167
55.24
GitHub Action Run
28 run-3.4-gemfiles/rails_8_0.gemfile - 32106065653.28 18 Aug 2026 06:15AM UTC 168
95.62
GitHub Action Run
29 run-3.3-gemfiles/rack_3_1.gemfile - 32106065653.29 18 Aug 2026 06:14AM UTC 167
95.62
GitHub Action Run
30 run-4.0-gemfiles/rails_8_1.gemfile - 32106065653.30 18 Aug 2026 06:14AM UTC 168
95.62
GitHub Action Run
31 run-3.4-gemfiles/rack_2_2.gemfile - 32106065653.31 18 Aug 2026 06:14AM UTC 167
95.58
GitHub Action Run
32 run-4.0-Gemfile - 32106065653.32 18 Aug 2026 06:14AM UTC 167
95.62
GitHub Action Run
Source Files on build 32106065653
  • Tree
  • List 168
  • Changed 3
  • Source Changed 3
  • Coverage Changed 3
Coverage ∆ File Lines Relevant Covered Missed Hits/Line Branch Hits Branch Misses
  • Back to Repo
  • Github Actions Build #32106065653
  • Pull Request #2840
  • PR Base - master (#31997173157)
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