Skip to content

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

Open

Description

@InterstellarStella

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

Activity

  1. linear commented on Jan 8, 2026

    @linear
  2. moved this to Waiting for: Product Owner in GitHub Issues with 👀 3on Jan 8, 2026
  3. changed the title [-]Transaction status incorrectly reports 500 (internal_error) instead of actual HTTP status code (e.g., 404) when Rails handles exceptions[/-] [+]Transaction status incorrectly reports 500 (internal_error) instead of actual HTTP status code (eg. 404) when Rails handles exceptions[/+] on Jan 8, 2026
  4. sl0thentr0py commented on Jan 8, 2026

    @sl0thentr0py
    Member

    Tried to reproduce but works correctly for me:

    with this simple resource show and calling it with an unknown id
    sl0thentr0py/sentry_sample_apps@9f6307a

    Image
  5. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 3on Jan 8, 2026
  6. moved this to Waiting for: Community in GitHub Issues with 👀 3on Jan 8, 2026
  7. self-assigned this
    on Jan 8, 2026
  8. getsantry commented on Jan 30, 2026

    @getsantry

    This issue has gone three weeks without activity. In another week, I will close it.

    But! If you comment or otherwise update it, I will reset the clock, and if you remove the label Waiting for: Community, I will leave it alone ... forever!


    "A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀

  9. solnic commented on Jan 30, 2026

    @solnic
    Collaborator

    @InterstellarStella could you share the version of Rails where this is happening?

  10. InterstellarStella commented on Feb 2, 2026

    @InterstellarStella
    Author

    @solnic the Rails version is 8.1.1. Adding some links in the Linear ticket.

  11. moved this from Waiting for: Community to Waiting for: Product Owner in GitHub Issues with 👀 3on Feb 2, 2026
  12. solnic commented on Feb 2, 2026

    @solnic
    Collaborator

    I think I reproduced it over here #2848 - @sl0thentr0py I'm happy to dig in, sounds good?

  13. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 3on Feb 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions