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

[10.x] Handle empty arrays for DynamoDbStore multi-key operations #46579

Merged
merged 1 commit into from
Mar 25, 2023

Conversation

nie7321
Copy link
Contributor

@nie7321 nie7321 commented Mar 24, 2023

When using the DynamoDB cache driver, if someone passes an empty list of keys to Cache::many([]) or an empty key/value array to Cache::putMany([]), DynamoDB will give an error response and the call will throw an exception. For example:

InvalidArgumentException: Found 1 error while validating the input provided for the BatchGetItem operation:
[RequestItems][vapor_cache][Keys] expected list element count to be >= 1, but found list element count of 0

This behaviour is unlike other cache drivers, which do not throw exceptions. For example:

>>> Cache::store('database')->many([])
=> []

>>> Cache::store('database')->putMany([])
=> true

That resulted in a papercut since I'm using the db driver for development and dynamo when deploying to vapor.

This PR adds a check for the array size and returns early if there's no Dynamo call to make.

@taylorotwell taylorotwell merged commit 6011968 into laravel:10.x Mar 25, 2023
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

Successfully merging this pull request may close these issues.

2 participants