Fix Ruby 2.3 compatibility in DeprecationTracker#180
Conversation
e4d3910 to
7c44e72
Compare
7c44e72 to
df305e9
Compare
Block parameter |k ,v| with space before comma may not parse correctly on Ruby 2.3. Changed to |k, v|.
…rmalized Only validate buckets actively tracked in the current run. Skip merged buckets from storage that aren't tracked now (e.g., tests removed). This avoids expensive file I/O and hash merging in compare mode when only current-run validation is needed.
5d237ce to
a9d47ae
Compare
| # not using `to_h` here to support older ruby versions | ||
| {}.tap do |h| | ||
| normalized.reject {|_key, value| value.empty? }.sort_by {|key, _value| key }.each do |k ,v| | ||
| normalized.reject {|_key, value| value.empty? }.sort_by {|key, _value| key }.each do |k, v| |
There was a problem hiding this comment.
TIL: This comma was getting Ruby 2.3 to fail
Ensures the method correctly merges, sorts, and deduplicates messages. Tests the block parameter syntax that broke on Ruby 2.3.
| end | ||
| end | ||
|
|
||
| describe "#normalized_deprecation_messages" do |
There was a problem hiding this comment.
Adding some tests to exercise the normalized_deprecation_messages method against old rubies
|
I don't understand why that's the issue, what is the actual error this is fixing? because I see this was working 3 commits before the last one
and the last one is NOT changing that code dd3cd15 it's totally unrelated to that I don't see the relationship between the change and the issue, and the error in CI mentions an unexpected deprecation warning, not a parsing failure
|
Fair point, I had the same thinking, like how this was passing before, should we just re-run CI? and wait on this. altho I think we want the change here: |
| changed_buckets = [] | ||
|
|
||
| normalized_deprecation_messages.each do |bucket, messages| | ||
| deprecation_messages.each do |bucket, messages| |
There was a problem hiding this comment.
@etagwerker @arielj is not needed but is nice to have, using the deprecation_messages saves the compare process to run the processes made inside of normalized_deprecation_messages.
not sure what is that fixing either, I have the same question as ernesto, why do you think it's a needed change? because the description of the PR is about fixing 2.3 compatibility and this change seems unrelated for the actual issue, I think we have to do more research, maybe ensure that we print the whole UnexpectedDeprecation error message in CI and that should help us figure out why sometimes it fails I suspect some filie is being created by another tests and used in the next_rails/lib/deprecation_tracker.rb Line 240 in d959bbc compare uses that same list of normalized deprecations to compare it)
|
yes is unrelated, I can open separated.
I re-run CI on main now passes, so, yes, we need to investigate more out there. |
|
I'll close this PR until we gather more data or can reproduce CI flaky tests |




Summary
Fix Ruby 2.3 compatibility issue in DeprecationTracker. The test "ignores buckets that have no messages" was failing on Ruby 2.3 CI but passing on 3.0+. Root cause: block parameter syntax
|k ,v|(space before comma) innormalized_deprecation_messagesnot supported on Ruby 2.3.Root Cause
Line 255 in
lib/deprecation_tracker.rb:The space before the comma in
|k ,v|causes block parameter parsing to fail on Ruby 2.3, breaking the entirenormalized_deprecation_messagesmethod.Fixes (3 commits)
Fix Ruby 2.3 block parameter syntax (972fdbb)
|k ,v|→|k, v|in normalized_deprecation_messagesSimplify compare mode (a9d47ae)
deprecation_messagesinstead ofnormalized_deprecation_messagesin compareAdd unit tests for normalized_deprecation_messages (d959bbc)
Why this works
normalized_deprecation_messageswork on Ruby 2.3deprecation_messagesin compare avoids the method entirely, making the fix more robust