[Django] #35384: Assigning a file without a name property to a FileField results in file getting discarded silently

15 views
Skip to first unread message

Django

unread,
Apr 17, 2024, 5:37:12 PM4/17/24
to django-...@googlegroups.com
#35384: Assigning a file without a name property to a FileField results in file
getting discarded silently
-------------------------------------+-------------------------------------
Reporter: john- | Owner: nobody
parton |
Type: Bug | Status: new
Component: Database | Version: 5.0
layer (models, ORM) |
Severity: Normal | Keywords:
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
If you assign a File object without a name (A ContentFile or otherwise) to
an instance and then save it, the storage backend is not invoked, the data
isn't persisted, and the column isn't updated. All without raising an
error or even a logger message.

We've isolated the behavior here: https://github.com/john-parton/django-
file-field-no-
name/blob/dc557c641552b02623f50ef044d73435b9e97ead/test_app/tests.py#L28-L41

There's some discussion here: https://forum.djangoproject.com/t/setting-
filefield-imagefield-where-file-has-no-name/30192/24
The general consensus is that some error should be raised.

I'll see if I can submit a patch. I flagged this as Database layer,
because the patch will likely be in models.files, not the storage backend.
--
Ticket URL: <https://code.djangoproject.com/ticket/35384>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Apr 18, 2024, 2:16:48 AM4/18/24
to django-...@googlegroups.com
#35384: Assigning a file without a name property to a FileField results in file
getting discarded silently
-------------------------------------+-------------------------------------
Reporter: john-parton | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version: 5.0
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Sarah Boyce):

* stage: Unreviewed => Accepted

Comment:

Thank you for the analysis and discussions 👍
--
Ticket URL: <https://code.djangoproject.com/ticket/35384#comment:1>

Django

unread,
Apr 18, 2024, 5:31:08 AM4/18/24
to django-...@googlegroups.com
#35384: Assigning a file without a name property to a FileField results in file
getting discarded silently
-------------------------------------+-------------------------------------
Reporter: john-parton | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version: 5.0
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Lily Foote):

* cc: Lily Foote (added)

--
Ticket URL: <https://code.djangoproject.com/ticket/35384#comment:2>

Django

unread,
Apr 24, 2024, 10:10:46 PM4/24/24
to django-...@googlegroups.com
#35384: Assigning a file without a name property to a FileField results in file
getting discarded silently
-------------------------------------+-------------------------------------
Reporter: john-parton | Owner: Jonny
| Park
Type: Bug | Status: assigned
Component: Database layer | Version: 5.0
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Jonny Park):

* owner: nobody => Jonny Park
* status: new => assigned

--
Ticket URL: <https://code.djangoproject.com/ticket/35384#comment:3>

Django

unread,
Apr 27, 2024, 10:41:29 PM4/27/24
to django-...@googlegroups.com
#35384: Assigning a file without a name property to a FileField results in file
getting discarded silently
-------------------------------------+-------------------------------------
Reporter: john-parton | Owner: Jonny
| Park
Type: Bug | Status: assigned
Component: Database layer | Version: 5.0
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Jonny Park):

* has_patch: 0 => 1

--
Ticket URL: <https://code.djangoproject.com/ticket/35384#comment:4>

Django

unread,
Apr 27, 2024, 11:07:57 PM4/27/24
to django-...@googlegroups.com
#35384: Assigning a file without a name property to a FileField results in file
getting discarded silently
-------------------------------------+-------------------------------------
Reporter: john-parton | Owner: Jonny
| Park
Type: Bug | Status: assigned
Component: Database layer | Version: 5.0
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Jonny Park):

The patch will still not pass `test_can_reread_content_file` at
https://github.com/john-parton/django-file-field-no-
name/blob/dc557c641552b02623f50ef044d73435b9e97ead/test_app/tests.py#L74-L83
I think it deserves it's own ticket and disccusion.
--
Ticket URL: <https://code.djangoproject.com/ticket/35384#comment:5>

Django

unread,
May 2, 2024, 5:13:39 AM5/2/24
to django-...@googlegroups.com
#35384: Assigning a file without a name property to a FileField results in file
getting discarded silently
-------------------------------------+-------------------------------------
Reporter: john-parton | Owner: Jonny
| Park
Type: Bug | Status: assigned
Component: Database layer | Version: 5.0
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Sarah Boyce):

* needs_better_patch: 0 => 1

--
Ticket URL: <https://code.djangoproject.com/ticket/35384#comment:6>

Django

unread,
May 10, 2024, 9:10:51 AM5/10/24
to django-...@googlegroups.com
#35384: Assigning a file without a name property to a FileField results in file
getting discarded silently
-------------------------------------+-------------------------------------
Reporter: john-parton | Owner: Jonny
| Park
Type: Bug | Status: assigned
Component: Database layer | Version: 5.0
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Sarah Boyce):

* needs_better_patch: 1 => 0

--
Ticket URL: <https://code.djangoproject.com/ticket/35384#comment:7>

Django

unread,
May 13, 2024, 2:35:56 AM5/13/24
to django-...@googlegroups.com
#35384: Assigning a file without a name property to a FileField results in file
getting discarded silently
-------------------------------------+-------------------------------------
Reporter: john-parton | Owner: Jonny
| Park
Type: Bug | Status: assigned
Component: Database layer | Version: 5.0
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Sarah Boyce):

* stage: Accepted => Ready for checkin

--
Ticket URL: <https://code.djangoproject.com/ticket/35384#comment:8>

Django

unread,
May 15, 2024, 6:02:56 AM5/15/24
to django-...@googlegroups.com
#35384: Assigning a file without a name property to a FileField results in file
getting discarded silently
-------------------------------------+-------------------------------------
Reporter: john-parton | Owner: Jonny
| Park
Type: Bug | Status: closed
Component: Database layer | Version: 5.0
(models, ORM) |
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Sarah Boyce <42296566+sarahboyce@…>):

* resolution: => fixed
* status: assigned => closed

Comment:

In [changeset:"c0b0ce85ede1f1baf8826fb6c10c23f9adcbcca3" c0b0ce8]:
{{{#!CommitTicketReference repository=""
revision="c0b0ce85ede1f1baf8826fb6c10c23f9adcbcca3"
Fixed #35384 -- Raised FieldError when saving a file without a name to
FileField.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/35384#comment:9>
Reply all
Reply to author
Forward
0 new messages