Fix a confusing crash creating a DiffCommit with no committer date.
Review Request #11317 — Created Dec. 7, 2020 and submitted
When creating a
DiffCommit
withcommitter_date=None
, which could
happen for some commits, we'd see a confusing error:TypeError: 'committer_date' is an invalid keyword argument for this function
This was a bit confusing because, although
committer_date
is a
property and not a model field, it clearly works in most situations
(we've been creating multi-commit review requests for some time now).The failure only manifests when passing
None
as the value, which led
to a crash in the property when trying to call a method on it. This
raised anAttributeError
, which triggered a handler in Django's
BaseModel
class, making it think thatcommitter_date
didn't exist.This change fixes the property to work with
None
values. It also
applies the same logic toauthor_date
, so that if aNone
is passed
in, we'll just setNone
in the fields, allowing Django's own
validation to occur.Unit tests were added for both of these properties.
Unit tests pass.
Hit this in production use and verified the fix.
Summary | ID |
---|---|
083e4ac1577706d2052fdcdbaf461917a374adda |
Description | From | Last Updated |
---|---|---|
F841 local variable 'commit' is assigned to but never used |
reviewbot |