Skip to content

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

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

Closed
1 task done
abbasyadollahi opened this issue Jun 14, 2023 · 4 comments · Fixed by #2468
Closed
1 task done
Assignees
Labels
documentation Improvements or additions to documentation event_sources Event Source Data Class utility

Comments

@abbasyadollahi
Copy link
Contributor

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.
@abbasyadollahi abbasyadollahi added documentation Improvements or additions to documentation triage Pending triage from maintainers labels Jun 14, 2023
@boring-cyborg
Copy link

boring-cyborg bot commented Jun 14, 2023

Thanks for opening your first issue here! We'll come back to you as soon as we can.
In the meantime, check out the #python channel on our Powertools for AWS Lambda Discord: Invite link

@rubenfonseca
Copy link
Contributor

@abbasyadollahi this is absolutely spot on, thank you for the clear explanation! Would you mind submit a PR for it? I can help you to quickly merge it :)

@rubenfonseca rubenfonseca added event_sources Event Source Data Class utility and removed triage Pending triage from maintainers labels Jun 15, 2023
@rubenfonseca rubenfonseca self-assigned this Jun 15, 2023
@abbasyadollahi
Copy link
Contributor Author

@rubenfonseca pushed out a PR with the changes, just a heads up, took the lazy route and didn't test it since it's just a docstring change 😅

@rubenfonseca rubenfonseca linked a pull request Jun 15, 2023 that will close this issue
7 tasks
@github-actions
Copy link
Contributor

⚠️COMMENT VISIBILITY WARNING⚠️

This issue is now closed. Please be mindful that future comments are hard for our team to see.

If you need more assistance, please either tag a team member or open a new issue that references this one.

If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation event_sources Event Source Data Class utility
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants