Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In Ruby repeated fields, each_index actually iterates over the index #11767

Conversation

shaldengeki
Copy link
Contributor

Currently we're aliasing each_index to each_with_index, incorrectly passing both the index and the value of a repeated field to the block.

What we want is to just pass the index. Luckily this is a method on Ruby arrays, so we just wrap the native Ruby array method.

Fixes #7806

@shaldengeki shaldengeki requested a review from a team as a code owner February 2, 2023 02:16
@shaldengeki shaldengeki requested review from esorot and removed request for a team February 2, 2023 02:16
@shaldengeki
Copy link
Contributor Author

Oh, hm. Should I not be working off of my fork? From the failing build:

This pull request is from an unsafe fork and hasn't been approved to run tests!

I can just branch off this repo, I suppose, if that's more convenient for y'all in the future.

@googleberg googleberg removed the request for review from esorot February 2, 2023 16:30
@mkruskal-google mkruskal-google added the 🅰️ safe for tests Mark a commit as safe to run presubmits over label Feb 2, 2023
@github-actions github-actions bot removed the 🅰️ safe for tests Mark a commit as safe to run presubmits over label Feb 2, 2023
@shaldengeki
Copy link
Contributor Author

@haberman 👋 Hi there! Anything I can do to help move this forward? (No worries if not, just making sure I'm not missing anything.)

@haberman
Copy link
Member

HI @shaldengeki, this looks good to me. I think the only question is whether we need to have a major version bump for this. Users could technically be relying on the old buggy behavior.

@shaldengeki
Copy link
Contributor Author

shaldengeki commented Feb 17, 2023 via email

@shaldengeki
Copy link
Contributor Author

@haberman just wanted to check in and set expectations -- let me know if I should be doing anything here.

@haberman
Copy link
Member

Thanks for checking in. No action is required on your part, I think we will plan to merge this in coordination with the next major version bump in Ruby, whenever that is (I think it will happen sometime this year).

@shaldengeki
Copy link
Contributor Author

@haberman apologies if this is noise - I see v24 release candidates are out, should we try to get this in?
https://github.com/protocolbuffers/protobuf/releases/tag/v24.0-rc3

@shaldengeki
Copy link
Contributor Author

@haberman happy Thanksgiving, and touching base once again on this; let me know what I can do to help.

@haberman
Copy link
Member

We are planning to bump the major version of Ruby in February. So it's time to move forward with a breaking change like this.

Thanks for your patience.

@zhangskz zhangskz added the 🅰️ safe for tests Mark a commit as safe to run presubmits over label Dec 26, 2023
@github-actions github-actions bot removed the 🅰️ safe for tests Mark a commit as safe to run presubmits over label Dec 26, 2023
copybara-service bot pushed a commit that referenced this pull request Dec 26, 2023
…11767)

Currently we're aliasing `each_index` to `each_with_index`, incorrectly passing both the index and the value of a repeated field to the block.

What we want is to just pass the index. Luckily this is a method on Ruby arrays, so we just wrap the native Ruby array method.

Fixes #7806

Closes #11767

COPYBARA_INTEGRATE_REVIEW=#11767 from shaldengeki:shaldengeki-repeated-field-each-index-returns-actual-index 874916c
FUTURE_COPYBARA_INTEGRATE_REVIEW=#11767 from shaldengeki:shaldengeki-repeated-field-each-index-returns-actual-index 874916c
PiperOrigin-RevId: 593820135
copybara-service bot pushed a commit that referenced this pull request Dec 26, 2023
…11767)

Currently we're aliasing `each_index` to `each_with_index`, incorrectly passing both the index and the value of a repeated field to the block.

What we want is to just pass the index. Luckily this is a method on Ruby arrays, so we just wrap the native Ruby array method.

Fixes #7806

Closes #11767

COPYBARA_INTEGRATE_REVIEW=#11767 from shaldengeki:shaldengeki-repeated-field-each-index-returns-actual-index 874916c
FUTURE_COPYBARA_INTEGRATE_REVIEW=#11767 from shaldengeki:shaldengeki-repeated-field-each-index-returns-actual-index 874916c
PiperOrigin-RevId: 593820135
copybara-service bot pushed a commit that referenced this pull request Dec 26, 2023
…11767)

Currently we're aliasing `each_index` to `each_with_index`, incorrectly passing both the index and the value of a repeated field to the block.

What we want is to just pass the index. Luckily this is a method on Ruby arrays, so we just wrap the native Ruby array method.

Fixes #7806

Closes #11767

COPYBARA_INTEGRATE_REVIEW=#11767 from shaldengeki:shaldengeki-repeated-field-each-index-returns-actual-index 874916c
PiperOrigin-RevId: 593835025
@haberman
Copy link
Member

This is now announced in https://protobuf.dev/news/2023-12-27/#ruby-breaking-changes

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.

ruby: repeated_field aliases each_index to each_with_index - thus incorrectly returning the each not the index
4 participants