Skip to content

Fix batch send_key crash in #size (use user_key_as_value)#17

Merged
zuchmanski merged 1 commit into
v5-developfrom
fix-batch-send-key-estimate-size
Jul 2, 2026
Merged

Fix batch send_key crash in #size (use user_key_as_value)#17
zuchmanski merged 1 commit into
v5-developfrom
fix-batch-send-key-estimate-size

Conversation

@zuchmanski

Copy link
Copy Markdown

Summary

BatchWrite#size, BatchUDF#size, and BatchDelete#size raised NoMethodError: undefined method 'estimate_size' for an instance of String whenever the batch record's policy had send_key: true. Since #size runs while estimating the wire buffer during batch_operate, any batch with send_key crashed before reaching the network.

Root cause

The three #size methods called @key.user_key.estimate_size, but Key#user_key returns the unwrapped raw value (@user_key.getString/Integer), and #estimate_size is defined only on Aerospike::Value. The single-record write path in command.rb already does this correctly via user_key_as_value.

Fix

Replace @key.user_key.estimate_size with @key.user_key_as_value.estimate_size in:

  • lib/aerospike/batch_write.rb
  • lib/aerospike/batch_udf.rb
  • lib/aerospike/batch_delete.rb

Verification

Reproduction from the report now runs cleanly for all three classes (previously raised):

BatchWrite:  36    # was: crash
BatchDelete: 17    # was: crash
BatchUDF:    38    # was: crash
control:     25    # send_key omitted, unchanged

🤖 Generated with Claude Code

BatchWrite#size, BatchUDF#size, and BatchDelete#size raised
NoMethodError: undefined method 'estimate_size' for a String whenever
the batch policy had send_key: true, crashing batch_operate before any
I/O.

Key#user_key returns the unwrapped raw value, but #estimate_size is
defined only on Aerospike::Value. Use #user_key_as_value instead,
matching the single-record write path in command.rb.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@zuchmanski
zuchmanski requested a review from madejejej July 2, 2026 09:08
@zuchmanski
zuchmanski marked this pull request as ready for review July 2, 2026 09:08
@zuchmanski
zuchmanski requested a review from mknapik July 2, 2026 09:08
@zuchmanski
zuchmanski merged commit 562ddb8 into v5-develop Jul 2, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants