• 
      

    Fix a confusing crash creating a DiffCommit with no committer date.

    Review Request #11317 — Created Dec. 7, 2020 and submitted — Latest diff uploaded

    Information

    Review Board
    release-4.0.x

    Reviewers

    When creating a DiffCommit with committer_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 an AttributeError, which triggered a handler in Django's
    BaseModel class, making it think that committer_date didn't exist.

    This change fixes the property to work with None values. It also
    applies the same logic to author_date, so that if a None is passed
    in, we'll just set None 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.

    Commits

    Files