dynamodb-toolbox icon indicating copy to clipboard operation
dynamodb-toolbox copied to clipboard

Fix crash due to string conversion of possible null prototype object

Open dburdan opened this issue 4 years ago • 7 comments

Fixes a bug that occurs when adding or updating an entity with an attribute that is an object with a null prototype.

Hopefully I understood the surrounding code correctly. If not, happy to update.

dburdan avatar Feb 09 '21 06:02 dburdan

Updated.

dburdan avatar Jul 05 '22 16:07 dburdan

Looks like a test is failing.

jeremydaly avatar Jul 05 '22 19:07 jeremydaly

@dburdan @naorpeled change data[field] == null to data[field] === null (strict equality) then tests pass 😄

Any reason for moving this out to a separate variable (fieldIsNullOrEmpty) rather than keeping it inline?

rbdmorgan avatar Jul 20 '22 15:07 rbdmorgan

@rbdmorgan Updated as suggested. IIRC codebase looked a bit different when the PR was made last year, but this should do.

dburdan avatar Jul 20 '22 16:07 dburdan

Nice @dburdan 👍🏼

@jeremydaly @naorpeled possible to re-run tests and get this merged?

rbdmorgan avatar Jul 20 '22 16:07 rbdmorgan

@rbdmorgan @dburdan will review this in a bit :)

naorpeled avatar Jul 20 '22 17:07 naorpeled

Not 100% sure wether we want to remove the attribute if provided an empty array.

@jeremydaly wdyt?

naorpeled avatar Jul 20 '22 18:07 naorpeled

Hey @dburdan, I've closed this PR because it would keep causing (the code already did that before, which wasn't right) the removal of empty arrays which is not a behavior I'd expect from removeNulls.

If you think otherwise let me know 🙏

naorpeled avatar Jan 08 '23 19:01 naorpeled

@naorpeled Sounds good!

dburdan avatar Jan 08 '23 19:01 dburdan