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
Erroneous DynamoDB SDK Validation Exception on a Query with a start key and a key condition with 'greater than or equals to' #2456
Comments
Sorry for the late response on this. Many of the SDK team were OOTO for vacation.
In general, these namespaced errors are returned by the service ( I'm not an expert with DynamoDB, but the docs suggest that you should use the
Looking at your use case, if I'm understanding correctly, you're making multiple calls after updating some instance variables (
|
Thanks, Matt. I'm glad that the team was OOTO and I had no expectations of a reply during the holidays. :) To answer your question re: the SDK's pagination feature, my code sends results (with the LastEvaluatedKey) to a client and the client returns the start key back to me if/when it wants another page. Hence, I'm not in a position to be able to use Does the stack trace indicate to you that this error is coming from the DynamoDB service and not the SDK? If so, perhaps I should raise this issue with AWS Customer Support? Could it be that the service is not interpreting the ">=" correctly in the query's key condition when it checks if the exclusive_start_key itself meets the condition? |
Yes - I believe this to be a service error. Although it's not defined in the model, we have a dynamic errors module that generates an error class on the fly based on the http response. If you are able to replicate locally, you can verify by checking the response after enabling |
I believe the issue here may be related to your usage of the Are you doing anything to modify the table during you're queries? I believe the error means that DynamoDB cannot get the item that the start_key references in the query. |
Thanks to both of you for helping me think through this. As far as I can tell, I am doing everything correct regarding the exclusive start key. Note: I can't take it immediately from the response because it round trips through my client (i.e. they tell me if they want another page). In any case, I should be able to detect this specific situation and skip the query altogether. Because my key condition asks for results where the sort key is I think that we can close this issue for now and I can re-open in the future if I have something new to add. |
|
Confirm by changing [ ] to [x] below to ensure that it's a bug:
Describe the bug
I believe that I have hit an erroneous DynamoDB SDK Validation Exception on a Query with a start key and a key condition:
Aws::DynamoDB::Errors::ValidationException: The provided starting key does not match the range key predicate
. I think that the error is telling me that the start key does not meet the key condition, but it in fact does.Gem name ('aws-sdk', 'aws-sdk-resources' or service gems like 'aws-sdk-s3') and its version
aws-sdk-dynamodb
Version of Ruby, OS environment
Ruby 2.6; Amazon Linux EC2 Instance
To Reproduce (observed behavior)
The code queries a DynamoDB table looking for items that were created before a specific time. It pages through in reverse chronological order, getting 10 items at a time, and setting the
exclusive_start_key
appropriately to get the next set of items. The query stops when it hits the specified time@beginning
.Expected behavior
The key condition specifies that the range key should be greater than or equal to a value
@beginning
, and yet I get this validation error when the range key specified in theexclusive_start_key
is equal to@beginning
. In general, this query works like a charm (because the range key in the start key is greater than@beginning
while my code pages through the query results), but once in a while when those two values become equal, I see this error in my logs. Is the ">=" not being interpreted correctly by the SDK or is my expectation of the condition wrong?Screenshots
n/a
Additional context
Relevant parts of the stack trace:
["/home/deploy/.bundler/myapp/ruby/2.6.0/gems/aws-sdk-core-3.97.1/lib/seahorse/client/plugins/raise_response_errors.rb:15:in call'",
"/home/deploy/.bundler/myapp/ruby/2.6.0/gems/aws-sdk-core-3.97.1/lib/aws-sdk-core/plugins/jsonvalue_converter.rb:20:in call'",
"/home/deploy/.bundler/myapp/ruby/2.6.0/gems/aws-sdk-core-3.97.1/lib/aws-sdk-core/plugins/idempotency_token.rb:17:in call'",
"/home/deploy/.bundler/myapp/ruby/2.6.0/gems/aws-sdk-core-3.97.1/lib/aws-sdk-core/plugins/param_converter.rb:24:in call'",
"/home/deploy/.bundler/myapp/ruby/2.6.0/gems/aws-sdk-core-3.97.1/lib/aws-sdk-core/plugins/response_paging.rb:10:in call'",
"/home/deploy/.bundler/myapp/ruby/2.6.0/gems/aws-sdk-core-3.97.1/lib/seahorse/client/plugins/response_target.rb:23:in call'",
"/home/deploy/.bundler/myapp/ruby/2.6.0/gems/aws-sdk-core-3.97.1/lib/seahorse/client/request.rb:70:in send_request'",
"/home/deploy/.bundler/myapp/ruby/2.6.0/gems/aws-sdk-dynamodb-1.48.0/lib/aws-sdk-dynamodb/client.rb:4068:in query'", ...
The text was updated successfully, but these errors were encountered: