lambdakiq
lambdakiq copied to clipboard
Exception in lambdakiq when a queue lacks a redrive policy
One of my jobs is raising an exception, which triggers lambdakiq's retry/redrive logic. As part of this, a reader is being called on Lambdakiq#Queue
:
def redrive_policy
@redrive_policy ||= JSON.parse(attributes['RedrivePolicy'])
end
Which queries the AWS SDK to find queue attributes:
def attributes
@attributes ||= client.get_queue_attributes({
queue_url: queue_url,
attribute_names: ['All']
}).attributes
end
However, my queue has no redrive policy defined, so attributes['RedrivePolicy']
has nil, so JSON.parse
raises.
Not a lambdakiq expert, so I'm not quite sure of the best fix -- redrive_policy
should probably return nil
, we should probably guard calls to it and return 1
as a max receive count in cases where a queue lacks redrive, e.g. right about here:
def max_receive_count
redrive_policy['maxReceiveCount'].to_i
end
This isn't a blocking issue for me (will go add a redrive policy) but I thought I would surface it, in case it's useful to you.
Thanks again for all of the nice tooling!