Skip to content
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

DynamoDB: empty update expression now returns a ValidationException #7989

Merged

Conversation

felixscherz
Copy link
Contributor

Hi, this is intended to fix an issue with dynamodb where an emtpy update expression given to update_item raises an unexpected exception: #7988

@felixscherz
Copy link
Contributor Author

I see some tests are failing, I'll have another look:)

Copy link
Collaborator

@bblommers bblommers left a comment

Choose a reason for hiding this comment

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

Hi @felixscherz, thanks for opening a PR for this!

The update_expression can be None when calling update_item in models, which would be absolutely valid. I would suggest to add this validation in responses.py instead, where the request first comes in:

update_expression = self.body.get("UpdateExpression", "").strip()

If the user-provided value is an empty string here, we should throw an exception - everything else can stay the same.

@felixscherz
Copy link
Contributor Author

Ok great, thanks for the help! I will have a look at the responses.py

Copy link

codecov bot commented Aug 16, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 94.37%. Comparing base (856ded1) to head (a7c2d93).
Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #7989   +/-   ##
=======================================
  Coverage   94.37%   94.37%           
=======================================
  Files        1125     1125           
  Lines       96369    96374    +5     
=======================================
+ Hits        90948    90953    +5     
  Misses       5421     5421           
Flag Coverage Δ
servertests 28.93% <0.00%> (-0.01%) ⬇️
unittests 94.34% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Collaborator

@bblommers bblommers left a comment

Choose a reason for hiding this comment

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

Great - thank you for adding this to Moto @felixscherz!

@bblommers bblommers added this to the 5.0.13 milestone Aug 16, 2024
@bblommers bblommers changed the title fix: empty update expression now returns a ValidationException DynamoDB: empty update expression now returns a ValidationException Aug 16, 2024
@bblommers bblommers merged commit 3827cce into getmoto:master Aug 16, 2024
50 checks passed
Copy link
Contributor

This is now part of moto >= 5.0.13.dev55

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.

DyanmoDB: empty update expression in update_item raises the wrong exception
2 participants