Skip to content

Fix Ruby 2.3 compatibility in DeprecationTracker#180

Closed
JuanVqz wants to merge 4 commits intomainfrom
fix/use-deprecation_messages-at-compare
Closed

Fix Ruby 2.3 compatibility in DeprecationTracker#180
JuanVqz wants to merge 4 commits intomainfrom
fix/use-deprecation_messages-at-compare

Conversation

@JuanVqz
Copy link
Copy Markdown
Member

@JuanVqz JuanVqz commented Apr 28, 2026

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) in normalized_deprecation_messages not supported on Ruby 2.3.

Root Cause

Line 255 in lib/deprecation_tracker.rb:

normalized.reject {|_key, value| value.empty? }.sort_by {|key, _value| key }.each do |k ,v|
  h[k] = v
end

The space before the comma in |k ,v| causes block parameter parsing to fail on Ruby 2.3, breaking the entire normalized_deprecation_messages method.

Fixes (3 commits)

  1. Fix Ruby 2.3 block parameter syntax (972fdbb)

    • Change |k ,v||k, v| in normalized_deprecation_messages
    • Resolves the parsing issue on Ruby 2.3
  2. Simplify compare mode (a9d47ae)

    • Use deprecation_messages instead of normalized_deprecation_messages in compare
    • Compare mode only runs on final merged shitlist (no node_index), so merging is redundant
    • Avoids expensive file I/O and hash operations
    • Semantically correct: only validate buckets tracked in current run
  3. Add unit tests for normalized_deprecation_messages (d959bbc)

    • Explicit tests for merge, sort, reject, and bucket ordering
    • Prevents regression of the Ruby 2.3 syntax issue
    • Closes the test coverage gap

Why this works

  • Comma fix makes normalized_deprecation_messages work on Ruby 2.3
  • Using deprecation_messages in compare avoids the method entirely, making the fix more robust
  • Together they ensure Ruby 2.3 compatibility while simplifying the code

@JuanVqz JuanVqz force-pushed the fix/use-deprecation_messages-at-compare branch 2 times, most recently from e4d3910 to 7c44e72 Compare April 28, 2026 21:42
@JuanVqz JuanVqz force-pushed the fix/use-deprecation_messages-at-compare branch from 7c44e72 to df305e9 Compare April 28, 2026 21:43
JuanVqz added 2 commits April 28, 2026 15:58
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.
@JuanVqz JuanVqz force-pushed the fix/use-deprecation_messages-at-compare branch from 5d237ce to a9d47ae Compare April 28, 2026 22:12
# 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|
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

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
Copy link
Copy Markdown
Member Author

@JuanVqz JuanVqz Apr 28, 2026

Choose a reason for hiding this comment

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

Adding some tests to exercise the normalized_deprecation_messages method against old rubies

@JuanVqz JuanVqz changed the title Fix: compare mode does not run on buckets Fix Ruby 2.3 compatibility in DeprecationTracker Apr 28, 2026
@JuanVqz JuanVqz requested review from arielj and etagwerker April 28, 2026 22:22
@JuanVqz JuanVqz marked this pull request as ready for review April 28, 2026 22:22
@arielj
Copy link
Copy Markdown

arielj commented Apr 29, 2026

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

image

and the last one is NOT changing that code dd3cd15

it's totally unrelated to that |k ,v| line, and that line was working just fine all this time

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

image

@JuanVqz
Copy link
Copy Markdown
Member Author

JuanVqz commented Apr 29, 2026

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

image and the last one is NOT changing that code [dd3cd15](https://github.com/fastruby/next_rails/commit/dd3cd158a85c7333990f10df7566eccc6d2ce40d)

it's totally unrelated to that |k ,v| line, and that line was working just fine all this time

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

image

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:
https://github.com/fastruby/next_rails/pull/180/changes#diff-6c04da937218edccfca173d994554d89b26424f47616cea3647470200d169372R187

changed_buckets = []

normalized_deprecation_messages.each do |bucket, messages|
deprecation_messages.each do |bucket, messages|
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@JuanVqz Why is this necessary?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@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.

@arielj
Copy link
Copy Markdown

arielj commented Apr 30, 2026

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: https://github.com/fastruby/next_rails/pull/180/changes#diff-6c04da937218edccfca173d994554d89b26424f47616cea3647470200d169372R187

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 compare method, and depending on the order of tests sometimes it's the correct file and sometimes it's the wrong file, but without knowing the root issue it's not clear to me why we want that change (if anything, the code that saves the file is using the normalized_deprecation_messages method

temp_file.write(JSON.pretty_generate(normalized_deprecation_messages))
, so I would expect that compare uses that same list of normalized deprecations to compare it)

@JuanVqz
Copy link
Copy Markdown
Member Author

JuanVqz commented Apr 30, 2026

because the description of the PR is about fixing 2.3 compatibility and this change seems unrelated

yes is unrelated, I can open separated.

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 re-run CI on main now passes, so, yes, we need to investigate more out there.

@JuanVqz
Copy link
Copy Markdown
Member Author

JuanVqz commented May 1, 2026

I'll close this PR until we gather more data or can reproduce CI flaky tests

@JuanVqz JuanVqz closed this May 1, 2026
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