Skip to content

Conversation

@solnic
Copy link
Collaborator

@solnic solnic commented Oct 28, 2025

#skip-changelog

@solnic solnic marked this pull request as ready for review October 28, 2025 13:23
@solnic solnic requested a review from sl0thentr0py October 28, 2025 13:23
@codecov
Copy link

codecov bot commented Oct 28, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.24%. Comparing base (f951c95) to head (cf8ee0b).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #2760   +/-   ##
=======================================
  Coverage   97.24%   97.24%           
=======================================
  Files         130      130           
  Lines        5229     5229           
=======================================
  Hits         5085     5085           
  Misses        144      144           
Components Coverage Δ
sentry-ruby 97.54% <ø> (ø)
sentry-rails 96.74% <ø> (ø)
sentry-sidekiq 95.05% <ø> (ø)
sentry-resque 94.44% <ø> (ø)
sentry-delayed_job 94.68% <ø> (ø)
sentry-opentelemetry 99.31% <ø> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Rails Version Compatibility Issue

The FILE_NAME case statement now returns nil for Rails versions below 5.2. Using this nil in require statements creates malformed paths, leading to LoadError exceptions. The resulting LoadError messages are unclear, not explicitly indicating an unsupported Rails version.

sentry-rails/spec/dummy/test_rails_app/app.rb#L25-L38

FILE_NAME =
case Gem::Version.new(Rails.version)
when ->(v) { v.between?(v5_2, v6_0) }
"5-2"
when ->(v) { v.between?(v6_0, v6_1) }
"6-0"
when ->(v) { v.between?(v6_1, v7_0) }
"6-1"
when ->(v) { v > v7_0 && v < v7_1 }
"7-0"
when ->(v) { v >= v7_1 }
"7-1"
end

Fix in Cursor Fix in Web


Comment on lines 27 to 30
case Gem::Version.new(Rails.version)
when ->(v) { v < v5_2 }
"5-0"
when ->(v) { v.between?(v5_2, v6_0) }
"5-2"
when ->(v) { v.between?(v6_0, v6_1) }
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Rails 7.0.0 incorrectly loads 6-1.rb config due to Gem::Version.between?'s inclusive upper bound, missing 7-0.rb specific configurations.
Severity: CRITICAL | Confidence: 1.00

🔍 Detailed Analysis

When running with Rails 7.0.0, the version selection logic incorrectly matches v.between?(v6_1, v7_0) because Gem::Version.between? is inclusive of both endpoints. This causes the application to load configs/6-1.rb and apps/6-1.rb instead of the correct 7-0.rb files. Consequently, Rails 7.0-specific configurations, such as Zeitwerk::Registry.loaders.clear, are not loaded, leading to incorrect application behavior or test failures.

💡 Suggested Fix

Adjust the version comparison for Rails 7.0.0. Either modify v.between?(v6_1, v7_0) to exclude the upper bound (e.g., v.between?(v6_1, Gem::Version.new("6.999.999"))) or change the subsequent condition to v >= v7_0 && v < v7_1.

🤖 Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: sentry-rails/spec/dummy/test_rails_app/app.rb#L27-L30

Potential issue: When running with Rails 7.0.0, the version selection logic incorrectly
matches `v.between?(v6_1, v7_0)` because `Gem::Version.between?` is inclusive of both
endpoints. This causes the application to load `configs/6-1.rb` and `apps/6-1.rb`
instead of the correct `7-0.rb` files. Consequently, Rails 7.0-specific configurations,
such as `Zeitwerk::Registry.loaders.clear`, are not loaded, leading to incorrect
application behavior or test failures.

Did we get this right? 👍 / 👎 to inform future reviews.

@solnic solnic merged commit 582aeb9 into master Oct 28, 2025
122 checks passed
@solnic solnic deleted the solnic/remove-rails-5.0-left-overs branch October 28, 2025 14:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants