Skip to content

Conversation

domderen
Copy link

Fix for issue #1287 (comment) When getting a model value with attributes_to_get parameter, set in a way where it could return an empty object, the get method is erronously throwing an exception even though the object exists. This fixes the issue.

…an empty item.

Fix for issue pynamodb#1287 (comment)
When getting a model value with `attributes_to_get` parameter, set in a way where it could return an empty object, the get method is erronously throwing an exception even though the object exists. This fixes the issue.
item_data = data.get(ITEM)
if item_data:
return cls.from_raw_data(item_data)
if ITEM in data:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably if data and ITEM in data:

@ikonst
Copy link
Contributor

ikonst commented Sep 16, 2025

Are you going to add a test?

@domderen
Copy link
Author

Hey, let me know whatt you think :)

@domderen
Copy link
Author

Hey, I updated the comments, and I removed the second test as indeed there were other places that already check if this exception is thrown when Item is not in the response.

In regards to better asserts, I'm now checking if the property we are trying to get indeed does not exist, even though the object is of correct type. Is this something more in line with your thinking?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants