Transaction status incorrectly reports 500 (internal_error) instead of actual HTTP status code (eg. 404) when Rails handles exceptions

Abierto
#2,825 6 comentarios 0 reacciones 1 asignado Ver en GitHub

Los mantenedores suelen responder en 2 días

@sl0thentr0py ya está trabajando en esto.

Desde el 8/1/2026.

  • #2848 de @solnic — cerrado sin fusionar

Evaluación

Este issue todavía no se ha evaluado.

Descripción

Bug Ruby sentry-rails Spans
Issue Description

When Rails handles an exception internally and converts it to a specific HTTP status code (e.g., ActiveRecord::RecordNotFound -> 404), the Sentry transaction is incorrectly reported with status internal_error and http.response.status_code: 500 instead of the actual HTTP response status code.

This creates inaccurate reports, as all Rails-rescued exceptions appear as 500 errors in Sentry, even though the client receives the correct HTTP status code (404, 422, etc.).

The breadcrumbs in the transaction correctly show the actual status code (404), but the transaction-level status and span-level status codes are incorrect (500).

Even though version 6.0.0+ includes trace_ignore_status_codes which by default excludes 404s from being traced, this is a workaround rather than a fix. The underlying issue of incorrect status code reporting remains for any status codes that are not ignored.

Reproduction Steps
  1. Configure a Rails application with sentry-rails version 5.27.0
  2. Enable tracing with config.traces_sample_rate = 1.0
  3. Create a route that raises ActiveRecord::RecordNotFound or similar exception that Rails rescues and converts to a 404 response
  4. Make a request to that route
  5. Examine the transaction in Sentry
Expected Behavior
  • Span status should be "not_found"
  • Span data.http.response.status_code should be 404
Actual Behavior
  • Span status is "internal_error"
  • Span data.http.response.status_code is 500
Ruby Version

Ruby 3.4.4

SDK Version

sentry-ruby: 5.27.0

Integration and Its Version

No response

Sentry Config

No response

Lenguaje dominante
Ruby
Estrellas
990
Forks
552
Merge medio
2 d 16 h
PR fusionados (30 d)
29

Preparar el entorno

Abrir en Codespaces

Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.

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 getsentry/sentry-ruby

Todos los issues de getsentry/sentry-ruby

Issues similares

Más issues de Ruby

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.