Opened 3 years ago

Closed 3 years ago

#17879 closed Bug (fixed)

Regression in serializers when using natural keys

Reported by: danfairs Owned by: kmtracey
Component: Core (Serialization) Version:
Severity: Release blocker Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

The Python serializer's handle_fk_field() method now no longer handles the case where a related object is None and natural keys are in use. The problem appears to have been introduced in this changeset:

https://code.djangoproject.com/changeset/17439

The code now no longer checks to see if the related object is not None before attempting to call natural_key() on it.

Attachments (1)

ticket17439.patch (3.5 KB) - added by tmitchell 3 years ago.
Test and fix

Download all attachments as: .zip

Change History (8)

comment:1 Changed 3 years ago by kmtracey

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

Upon inspection this appears to be a regression therefore marking as release blocker. I don't supposed you have a test?

comment:2 Changed 3 years ago by aaugustin

  • Severity changed from Normal to Release blocker

comment:3 Changed 3 years ago by danfairs

Not yet - I'll try to put one together as soon as I can (realistically, over the next day or so.)

comment:4 Changed 3 years ago by tmitchell

Working on this right now @ the PyCon sprints

Changed 3 years ago by tmitchell

Test and fix

comment:5 Changed 3 years ago by tmitchell

  • Has patch set
  • Triage Stage changed from Unreviewed to Accepted
  • Type changed from Uncategorized to Bug

D'oh referenced the wrong ticket in the patch, but the patch is for this ticket.

comment:6 Changed 3 years ago by kmtracey

  • Owner changed from nobody to kmtracey

comment:7 Changed 3 years ago by kmtracey

  • Resolution set to fixed
  • Status changed from new to closed

In [17685]:

Fix #17879: Corrected regression in python (inherited by yaml and json) serializer that prevented serializing model instances with null FK ref to a model when serializing with natural keys. Thanks danfairs and tmitchell.

Note: See TracTickets for help on using tickets.
Back to Top