Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

Let a `rescue_from` handler propagate an exception instead of rendering it

Abierto
#3,003 2 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
45/100
Tipo de issue
Nueva funcionalidad
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
rails, ruby
Área
api, backend

Línea de trabajo

Look at the rescue_from handling in lib/grape/middleware/error.rb and lib/grape/dsl/inside_route.rb. Understand how exceptions are caught and redispatched since #2703. The change involves adding a propagate option to rescue_from, similar to the raise_rendering_errors config. Check existing tests for rescue_from to see how to add new behavior.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Since #2703 (3.3.0) an exception raised inside a rescue_from block is caught and redispatched instead of escaping the middleware stack. That fixed #2482, and it also removed the only way an app could let a specific exception class reach Rack middleware mounted above Grape. There's no opt-out today.

The case I hit: Rails' ActiveRecord::Middleware::DatabaseSelector routes a request to a read replica, and a custom config.active_record.database_resolver can catch ActiveRecord::ReadOnlyError and retry the block against the primary. The app re-raised that error from rescue_from(:all) so the resolver upstream could do its job. On 3.3+ it no longer gets there, so the request 500s where it used to recover, and nothing notices, since the redispatch renders an ordinary 500.

env['grape.exception'] (#2855) is enough to report the exception but not to act on it, because the response is already built by then. Raising a non-StandardError does escape, but it bypasses every intervening rescue => e. Dropping rescue_from :all gives up the catch-all for everything else, and #2737 makes excluding a single class from it an ArgumentError.

#2840 made the same call for the rendering case and added Grape.config.raise_rendering_errors to opt back out. I'd like the equivalent for the handler case:

rescue_from ActiveRecord::ReadOnlyError, propagate: true

Verified the behavior above against 4.0.1. Happy to open a PR if the direction seems right.

Lenguaje dominante
Ruby
Estrellas
10k
Forks
1.2k
Merge medio
13 h 13 min
PR fusionados (30 d)
115

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de ruby-grape/grape

Todos los issues de ruby-grape/grape

Issues similares

Más issues de Ruby

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.