Skip to content

Docs: Type mismatch for N attributes in dynamo_db_stream_event.TypeDeserializer  #2462

Closed
@abbasyadollahi

Description

@abbasyadollahi

What were you searching in the docs?

I wasn't sure which type of issue this is, but felt like documentation was the most appropriate.

After fetching an N attribute from a DynamoDB StreamRecord, I get a Decimal object (as expected given the _deserialize_n method), although the deserialize docstring indicates that it should be a str.

@event_source(data_class=DynamoDBStreamEvent)
def handler(event: DynamoDBStreamEvent, context: LambdaContext) -> None:
    for record in event.records:
        print(type(record.dynamodb.new_image.get("Timestamp")))

>>> <class 'decimal.Decimal'>

Is this related to an existing documentation section?

https://github.com/awslabs/aws-lambda-powertools-python/blob/develop/aws_lambda_powertools/utilities/data_classes/dynamo_db_stream_event.py#L42

How can we improve?

Just need to update the deserializer docstring, easy fix.

Before:

"""
{'N': str(value)}                       str(value)
"""

After:

"""
{'N': Decimal(value)}                   Decimal(value)
"""

Got a suggestion in mind?

No response

Acknowledgment

  • I understand the final update might be different from my proposed suggestion, or refused.

Metadata

Metadata

Assignees

Labels

documentationImprovements or additions to documentationevent_sourcesEvent Source Data Class utility

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions