Skip to content

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

Closed

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.

Activity

  1. added
    documentationImprovements or additions to documentation
    triagePending triage from maintainers
    on Jun 14, 2023
  2. boring-cyborg commented on Jun 14, 2023

    @boring-cyborg

    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

  3. rubenfonseca commented on Jun 15, 2023

    @rubenfonseca
    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 :)

  4. added
    event_sourcesEvent Source Data Class utility
    and removed
    triagePending triage from maintainers
    on Jun 15, 2023
  5. self-assigned this
    on Jun 15, 2023
  6. abbasyadollahi commented on Jun 15, 2023

    @abbasyadollahi
    ContributorAuthor

    @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 😅

  7. github-actions commented on Jun 16, 2023

    @github-actions
    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

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