DynamoDB Query Bug with request_limit and range_key_condition #1434

Open
maiku2000 opened this Issue Apr 10, 2013 · 5 comments

Projects

None yet

4 participants

@maiku2000

There appears to be a bug if I specify both range_key_condition and request_limit (it appears to work ok if I use max_results instead but that is a different method of limiting results).

results = dynamo_conn.query(input_table, hash_key=1, range_key_condition=LT(
end_timestamp), request_limit=25)
results.count
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python27\lib\site-packages\boto\dynamodb\layer2.py", line 67, in count
    self.response
  File "C:\Python27\lib\site-packages\boto\dynamodb\layer2.py", line 92, in response
    return self.next_response() if self._response is None else self._response
  File "C:\Python27\lib\site-packages\boto\dynamodb\layer2.py", line 104, in next_response
    self._response = self.callable(**self.kwargs)
  File "C:\Python27\lib\site-packages\boto\dynamodb\layer1.py", line 528, in query
    object_hook=object_hook)
  File "C:\Python27\lib\site-packages\boto\dynamodb\layer1.py", line 118, in make_request
    retry_handler=self._retry_handler)
  File "C:\Python27\lib\site-packages\boto\connection.py", line 845, in _mexe
    status = retry_handler(response, i, next_sleep)
  File "C:\Python27\lib\site-packages\boto\dynamodb\layer1.py", line 155, in _retry_handler
    response.status, response.reason, data)
boto.dynamodb.exceptions.DynamoDBValidationError: DynamoDBValidationError: 400 B
ad Request
{u'message': u"1 validation error detected: Value '-1' at 'limit' failed to satisfy constraint: Member must have value greater than or equal to 1", u'__type': u
'com.amazon.coral.validate#ValidationException'}

It likewise errors out if I try look at the "response" attribute of this TableGenerator.

@disruptek

Can you confirm that this bug is present in the develop branch?

@maiku2000
@disruptek

This issue fixed in #1248, which means you need 2.9+ for the fix.

@mgranlund

It seems as though this hasn't yet been fixed in dynamodb2?

@mwaterfall

@disruptek This (or a similar issue) is present in DynamoDB2 (Boto 2.9.5). In the following example, the query limit is set to 1 and there are 2 items in the table.

Traceback (most recent call last):
  File "ddb2.py", line 17, in <module>
    consistent=False
  File "/Users/mwaterfall/.pythonbrew/pythons/Python-2.7.3/lib/python2.7/site-packages/boto/dynamodb2/results.py", line 59, in next
    self.fetch_more()
  File "/Users/mwaterfall/.pythonbrew/pythons/Python-2.7.3/lib/python2.7/site-packages/boto/dynamodb2/results.py", line 108, in fetch_more
    results = self.the_callable(*args, **kwargs)
  File "/Users/mwaterfall/.pythonbrew/pythons/Python-2.7.3/lib/python2.7/site-packages/boto/dynamodb2/table.py", line 761, in _query
    **kwargs
  File "/Users/mwaterfall/.pythonbrew/pythons/Python-2.7.3/lib/python2.7/site-packages/boto/dynamodb2/layer1.py", line 967, in query
    body=json.dumps(params))
  File "/Users/mwaterfall/.pythonbrew/pythons/Python-2.7.3/lib/python2.7/site-packages/boto/dynamodb2/layer1.py", line 1479, in make_request
    retry_handler=self._retry_handler)
  File "/Users/mwaterfall/.pythonbrew/pythons/Python-2.7.3/lib/python2.7/site-packages/boto/connection.py", line 852, in _mexe
    status = retry_handler(response, i, next_sleep)
  File "/Users/mwaterfall/.pythonbrew/pythons/Python-2.7.3/lib/python2.7/site-packages/boto/dynamodb2/layer1.py", line 1518, in _retry_handler
    response.status, response.reason, data)
boto.dynamodb2.exceptions.ValidationException: ValidationException: 400 Bad Request
{u'message': u"1 validation error detected: Value '0' at 'limit' failed to satisfy constraint: Member must have value greater than or equal to 1", u'__type': u'com.amazon.coral.validate#ValidationException'}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment