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

XAUTOCLAIM throws NoMethodError if entry is nil #1165

Closed
wcmonty opened this issue Nov 17, 2022 · 1 comment
Closed

XAUTOCLAIM throws NoMethodError if entry is nil #1165

wcmonty opened this issue Nov 17, 2022 · 1 comment

Comments

@wcmonty
Copy link
Contributor

wcmonty commented Nov 17, 2022

If an entry in the PEL is deleted, xautoclaim returns nil for the event in the response. When processing that event, it is passed to the HashifyStreamAutoclaim lambda where it throws an error because the lambda assumes there's an actual event. See the following sample script. I tested with v4.5.1, but it looks like the lambda is unchanged in the current version.

redis.xgroup(:create, 'key', 'group1', '$', mkstream: true)
# => "OK"
redis.xadd('key', { foo: :bar }, id: '1')
# => "1-0"
redis.xreadgroup('group1', 'consumer1', 'key', '>', count: 1)
# => {"key"=>[["1-0", {"foo"=>"bar"}]]}
redis.xdel('key', '1-0')
# => 1
redis.xautoclaim('key', 'group1', 'consumer2', 0, '0-0', count: 1)
# NoMethodError: undefined method `[]' for nil:NilClass
# 
#      'entries' => reply[1].map { |entry| [entry[0], entry[1].each_slice(2).to_h] }
#                                                ^^^
# from /usr/local/bundle/gems/redis-4.5.1/lib/redis.rb:3704:in `block (2 levels) in <class:Redis>'

This is similar to #905. It looks like Redis server is changing its behavior as of v7.0, so this will no longer be an issue.

I think the solution is to compact the array before we map over it.

@byroot
Copy link
Collaborator

byroot commented Nov 18, 2022

Fixed in #1166

@byroot byroot closed this as completed Nov 18, 2022
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

No branches or pull requests

2 participants