protocolbuffers / protocolbuffers/protobuf

[Ruby] RepeatedField#values_at is aliased to Enumerable#select

Open Beginner friendly
#29,516 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C++
Stars
72k
Forks
16.3k
Avg merge
1d 17h
Merged PRs (30d)
140

Description

Summary

Ruby Google::Protobuf::RepeatedField#values_at is currently aliased to Enumerable#select. It therefore expects a block and raises ArgumentError for the index/range arguments required by the Array-like API.

Reproduction

On current main (5b1c20741838b8359193b97895cb0ff35b4ecf79) and 4.36.0, create a typed repeated field containing three values and call values_at(0, -1, 10, 1..2). The call raises instead of returning the corresponding values and nil for the out-of-range index.

Proposed correction

Delegate values_at to to_ary, alongside the other non-mutating Array methods, and remove the incorrect alias. Candidate: c9fc1c901baa2b6ab4d0d48dd1d509f6a30a9708.

The isolated model passes full positive/negative/out-of-range/range semantics. The cumulative candidate passes 332 native tests /556,948 assertions and 329 FFI tests /598,403 assertions with no failures or errors (documented omissions only), plus Songstats schema round-trips.

I used an AI coding assistant during source review and verification. I am opening an issue first because CONTRIBUTING asks for tests and maintainer agreement; this dependency audit is not permitted to modify repository tests and no CLA was signed as part of it.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Locate Ruby's Google::Protobuf::RepeatedField#values_at implementation and the nearby non-mutating Array method delegations. Compare the proposed correction at commit c9fc1c901baa2b6ab4d0d48dd1d509f6a30a9708, then run the native and FFI test suites and the Songstats schema round-trips. Done means index, negative-index, range, and out-of-range behavior works without failures or errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
api
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
72/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.