Search code examples
amazon-dynamodb

Function URL display records irrespective of an error


I have a python lambda function that connects to dynamoDB. The following line is causing an error in cloudatch.

response_list = client.scan(
ExpressionAttributeValues = {":nitin_nature": {'N':search_term}}, 
FilterExpression='id = :nitin_nature', 
TableName='activitylg', 
ProjectionExpression='#ST, #AT', 
ExpressionAttributeNames={ '#AT': 'dt', '#ST': 'code', },   

Error is:

[ERROR] ClientError: An error occurred (ValidationException) when calling the Scan operation: ExpressionAttributeValues contains invalid value: The parameter cannot be converted to a numeric value for key :nitin_nature

But the fact is that it shows the correct records (using function URL) even if there is an error. I am not sure how does the function even completes :)

I can ignore the error since I get the correct expected records. But I will like to know the reason.


Solution

  • Your exception is telling your that search_term is not convertible to a Number type in DynamoDB.

    If your using the low level client, which I assume you are based on syntax, then ensure that search_term is a string value that represents a number. It cannot contain Null or None, as it must always be convertible to a Number type.