我有一个连接到 dynamoDB 的 python lambda 函数。以下行在 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] 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
但事实是,即使有错误,它也会显示正确的记录(使用函数 URL)。 我不确定这个功能是如何完成的:)
我可以忽略该错误,因为我得到了正确的预期记录。但我想知道原因。
您的例外情况是告诉您
search_term
无法转换为 DynamoDB 中的数字类型。
如果您使用低级客户端(我假设您基于语法),请确保
search_term
是表示数字的字符串值。它不能包含 Null 或 None,因为它必须始终可转换为 Number 类型。