[Ruby] Blockless RepeatedField mutators return corrupting proxy enumerators

Open
#29,517 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

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

Research direction

Start by locating the Ruby RepeatedField mutator implementations and the 38-line ProxyingEnumerator described in the issue. Compare blockless delete_if, select!, collect!, and sort_by! with Array enumerator behavior, then use the isolated model and native/FFI test suites to verify receiver and nil-result semantics. Done means blockless calls return a correct enumerator without corrupting typed fields.

Written by the indexing model from the issue text.

Description

Summary

Blockless RepeatedField mutators such as delete_if, select!, collect!, and sort_by! return ProxyingEnumerator. Its each writes the block's predicate/transformation result directly into field slots, so predicate methods try to assign booleans into typed fields and transformation semantics diverge from Array.

Reproduction

On current main (5b1c20741838b8359193b97895cb0ff35b4ecf79) and 4.36.0, call field.delete_if without a block, then execute the returned enumerator with a predicate. An integer field attempts to accept true/false, producing a type error instead of deleting selected values.

Proposed correction

Return enum_for(method_name, *args) when the Array operation yields an Enumerator. When a block is later supplied, the wrapper re-invokes the real mutator and preserves its normal receiver/nil result contract; the broken 38-line proxy can be removed. Candidate: 40851eeb900925559ca730aa845be4301e746f36.

The isolated model covers the blockless mutator family and receiver/nil 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).

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.

Dominant language
C++
Stars
72.2k
Forks
16.4k
Avg merge
1d 8h
Merged PRs (30d)
342

Getting set up

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.

More from protocolbuffers/protobuf

All issues in protocolbuffers/protobuf

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.