Opened 5 years ago
Closed 5 years ago
#31219 closed Bug (fixed)
Raising error about protected related objects can crash.
Reported by: | Matthias Kestenholz | Owned by: | Matthias Kestenholz |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | dev |
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 (last modified by )
====================================================================== ERROR: test_protect_via (delete.tests.OnDeleteTests) ---------------------------------------------------------------------- Traceback (most recent call last): File "/usr/lib/python3.6/unittest/case.py", line 59, in testPartExecutor yield File "/usr/lib/python3.6/unittest/case.py", line 605, in run testMethod() File "/home/matthias/Projects/django/tests/delete/tests.py", line 99, in test_protect_via p.delete() File "/home/matthias/Projects/django/django/db/models/base.py", line 941, in delete collector.collect([self], keep_parents=keep_parents) File "/home/matthias/Projects/django/django/db/models/deletion.py", line 300, in collect error.protected_objects[0].__class__.__name__, TypeError: 'itertools.chain' object is not subscriptable
Pull request follows.
(By the way, this came up while testing https://groups.google.com/forum/?utm_medium=email&utm_source=footer#!msg/django-developers/WmgqJnQ6ioE/b52uACoPAgAJ / the JSONField GSoC pull request. Apart from this crash everything worked fine!)
Change History (7)
comment:1 by , 5 years ago
comment:2 by , 5 years ago
Description: | modified (diff) |
---|
comment:3 by , 5 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:4 by , 5 years ago
Has patch: | set |
---|---|
Owner: | changed from | to
Severity: | Normal → Release blocker |
Status: | new → assigned |
Summary: | PROTECT may crash in some situations → Raising error about protected fields can crash. |
comment:5 by , 5 years ago
Summary: | Raising error about protected fields can crash. → Raising error about protected related objects can crash. |
---|
Thanks for this report, it looks that something is also wrong in the error message.
Bumping to a release blocker (Django 3.1) because it's a regression in ab3cbd8b9a315911248227208630a020cedca08f.
We probably create a similar regression in 4ca5c565f4dc9e97845036e86416abc5cfde766c for restricted related objects. Can you check if they are also affected?
comment:6 by , 5 years ago
I added another commit on top (https://github.com/django/django/pull/12394/commits/42fb622f8895f59ff6ad76b761c1eb9b41fd9549) which tests the RESTRICT
case.
The RESTRICT
case shows a foreign key which actually exists, but it does not point at the P
object yet but at the intermediate R
object. It does not crash because there is no code accessing the first restricted object as is the case with protected objects.
PR