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

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

Build:
Build:
LAST BUILD BRANCH: fix/adversarial-sweep-2026-08
DEFAULT BRANCH: master
Ran 29 Jul 2026 09:07PM UTC
Jobs 32
Files 167
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

29 Jul 2026 09:06PM UTC coverage: 96.983% (+0.007%) from 96.976%
30491097069

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.

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. The exception that defeated rendering is put on
env['grape.exception'], the key the existing unrecognised-error path already
uses, so upstream loggers can still observe it.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Pull Request #2840: Answer 500 when an error response cannot be rendered

1196 of 1285 branches covered (93.07%)

Branch coverage included in aggregate %.

3818 of 3885 relevant lines covered (98.28%)

26720.53 hits per line

Coverage Regressions

Lines Coverage ∆ File
6
94.37
0.47% lib/grape/middleware/error.rb
Jobs
ID Job ID Ran Files Coverage
1 run-3.3-gemfiles/rails_7_2.gemfile - 30491097069.1 29 Jul 2026 09:08PM UTC 167
95.61
GitHub Action Run
2 run-4.0-gemfiles/grape_swagger.gemfile - 30491097069.2 29 Jul 2026 09:08PM UTC 166
55.4
GitHub Action Run
3 run-4.0-gemfiles/rails_8_1.gemfile - 30491097069.3 29 Jul 2026 09:08PM UTC 167
95.61
GitHub Action Run
4 run-4.0-Gemfile - 30491097069.4 29 Jul 2026 09:08PM UTC 166
95.6
GitHub Action Run
5 run-3.3-gemfiles/rails_8_0.gemfile - 30491097069.5 29 Jul 2026 09:08PM UTC 167
95.61
GitHub Action Run
6 run-3.4-gemfiles/rails_8_0.gemfile - 30491097069.6 29 Jul 2026 09:08PM UTC 167
95.61
GitHub Action Run
7 run-3.4-gemfiles/rack_3_0.gemfile - 30491097069.7 29 Jul 2026 09:07PM UTC 166
95.6
GitHub Action Run
8 run-3.4-gemfiles/rails_7_2.gemfile - 30491097069.8 29 Jul 2026 09:08PM UTC 167
95.61
GitHub Action Run
9 run-3.4-gemfiles/rack_3_2.gemfile - 30491097069.9 29 Jul 2026 09:08PM UTC 166
95.6
GitHub Action Run
10 run-4.0-gemfiles/multi_xml.gemfile - 30491097069.10 29 Jul 2026 09:08PM UTC 166
47.21
GitHub Action Run
11 run-4.0-gemfiles/rack_3_0.gemfile - 30491097069.11 29 Jul 2026 09:08PM UTC 166
95.6
GitHub Action Run
12 run-4.0-gemfiles/rails_7_2.gemfile - 30491097069.12 29 Jul 2026 09:08PM UTC 167
95.61
GitHub Action Run
13 run-4.0-gemfiles/dry_validation.gemfile - 30491097069.13 29 Jul 2026 09:08PM UTC 166
58.09
GitHub Action Run
14 run-3.3-Gemfile - 30491097069.14 29 Jul 2026 09:07PM UTC 166
95.6
GitHub Action Run
15 run-4.0-gemfiles/grape_entity.gemfile - 30491097069.15 29 Jul 2026 09:08PM UTC 166
50.5
GitHub Action Run
16 run-3.4-gemfiles/rack_3_1.gemfile - 30491097069.16 29 Jul 2026 09:07PM UTC 166
95.6
GitHub Action Run
17 run-4.0-gemfiles/multi_xml_0_8.gemfile - 30491097069.17 29 Jul 2026 09:08PM UTC 166
47.25
GitHub Action Run
18 run-3.4-Gemfile - 30491097069.18 29 Jul 2026 09:07PM UTC 166
95.6
GitHub Action Run
19 run-3.3-gemfiles/rack_2_2.gemfile - 30491097069.19 29 Jul 2026 09:08PM UTC 166
95.57
GitHub Action Run
20 run-4.0-gemfiles/multi_json.gemfile - 30491097069.20 29 Jul 2026 09:07PM UTC 166
47.81
GitHub Action Run
21 run-3.3-gemfiles/rack_3_1.gemfile - 30491097069.21 29 Jul 2026 09:07PM UTC 166
95.6
GitHub Action Run
22 run-4.0-gemfiles/hashie.gemfile - 30491097069.22 29 Jul 2026 09:08PM UTC 166
62.01
GitHub Action Run
23 run-3.4-gemfiles/rack_2_2.gemfile - 30491097069.23 29 Jul 2026 09:08PM UTC 166
95.57
GitHub Action Run
24 run-4.0-gemfiles/multi_json_1_20.gemfile - 30491097069.24 29 Jul 2026 09:08PM UTC 166
47.85
GitHub Action Run
25 run-3.4-gemfiles/rails_8_1.gemfile - 30491097069.25 29 Jul 2026 09:07PM UTC 167
95.61
GitHub Action Run
26 run-3.3-gemfiles/rack_3_2.gemfile - 30491097069.26 29 Jul 2026 09:08PM UTC 166
95.6
GitHub Action Run
27 run-4.0-gemfiles/rails_8_0.gemfile - 30491097069.27 29 Jul 2026 09:08PM UTC 167
95.59
GitHub Action Run
28 run-4.0-gemfiles/rack_2_2.gemfile - 30491097069.28 29 Jul 2026 09:08PM UTC 166
95.57
GitHub Action Run
29 run-3.3-gemfiles/rack_3_0.gemfile - 30491097069.29 29 Jul 2026 09:08PM UTC 166
95.6
GitHub Action Run
30 run-3.3-gemfiles/rails_8_1.gemfile - 30491097069.30 29 Jul 2026 09:08PM UTC 167
95.61
GitHub Action Run
31 run-4.0-gemfiles/rack_3_1.gemfile - 30491097069.31 29 Jul 2026 09:07PM UTC 166
95.6
GitHub Action Run
32 run-4.0-gemfiles/rack_3_2.gemfile - 30491097069.32 29 Jul 2026 09:08PM UTC 166
95.6
GitHub Action Run
Source Files on build 30491097069
  • Tree
  • List 167
  • Changed 3
  • Source Changed 1
  • Coverage Changed 3
Coverage ∆ File Lines Relevant Covered Missed Hits/Line Branch Hits Branch Misses
  • Back to Repo
  • Github Actions Build #30491097069
  • Pull Request #2840
  • PR Base - master (#30486032579)
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