Disallow uploading diffs larger than 1 megabyte.

Review Request #2984 — Created March 19, 2012 and submitted

Information

Review Board
release-1.6.x

Reviewers

Disallow uploading diffs larger than 1 megabyte.

When diffs are particularly large, they can cause the server to spin at 100% CPU
for a very long time. This is normally not a problem (who changes that much code
at a time?), but parent diffs make it easier to hit.

This change fixes it pretty well for the upload forms on the web site.
post-review will also fail to upload, although the error message it prints out
is especially bad (it says that the diff file is empty).
Tested with a local instance. Posted a review with a parent branch of
release-1.0.x and saw post-review error out.
Description From Last Updated

I'd say we can just nuke this now. We're changing the error code so no reason to preserve this compatibility.

chipx86chipx86

Hmm, maybe it'd be nice to specify the max size as a field too?

chipx86chipx86

Other errors use "reason", so maybe we should go with that. Kinda wish we could just stick it in err.msg …

chipx86chipx86
chipx86
  1. Can you add an except: for this in webapi/resources.py (around line 1521 here), and an error code in webapi/errors.py? That'll give us a better error we can track, and I can update RBTools to do that.
    1. Actually, while you're at it, we should have a more specific error for empty diffs. Then we can stop printing the wrong error for various form validation problems.
  2. 
      
david
chipx86
  1. 
      
  2. reviewboard/webapi/resources.py (Diff revision 2)
     
     
     
     
    Show all issues
    I'd say we can just nuke this now. We're changing the error code so no reason to preserve this compatibility.
  3. reviewboard/webapi/resources.py (Diff revision 2)
     
     
    Show all issues
    Other errors use "reason", so maybe we should go with that. Kinda wish we could just stick it in err.msg though. Oh well.
  4. 
      
chipx86
  1. 
      
  2. reviewboard/webapi/resources.py (Diff revision 2)
     
     
    Show all issues
    Hmm, maybe it'd be nice to specify the max size as a field too?
  3. 
      
david
chipx86
  1. Ship It!
  2. 
      
david
Review request changed
Status:
Completed
Change Summary:
Pushed to release-1.6.x (d150506).