#30908 closed Bug (wontfix)
FilePathField raises FileNotFoundError for nonexistent path.
Reported by: | Jason Held | Owned by: | Hasan Ramezani |
---|---|---|---|
Component: | Forms | Version: | 2.2 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Accepted | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | yes | UI/UX: | no |
Description
The docs around the model of FilePathField show the path as being default None, while the code is empty string.
Also, due to a change in 2.2 around using scandir on the form field for FilePathField, if the path doesn't exist, a FileNotFoundError is issued (same would have happened before the scandir change), but now the try/except logic on OSError (super class) has been removed, in the PR that changed to scandir.
So, the docs are out of date (regardless of whichever value is more sane as a default), and the change on scandir also removed the try/except.
Previously it was not an issue because there was a try/except, so we were caught off guard.
Attachments (1)
Change History (9)
comment:1 by , 5 years ago
Component: | Uncategorized → Forms |
---|---|
Easy pickings: | set |
Severity: | Normal → Release blocker |
Summary: | FilePathField doc & field scan dir issue → FilePathField raises FileNotFoundError for nonexistent path. |
Triage Stage: | Unreviewed → Accepted |
Type: | Uncategorized → Bug |
comment:5 by , 5 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:6 by , 5 years ago
Resolution: | → wontfix |
---|---|
Severity: | Release blocker → Normal |
Status: | assigned → closed |
Sorry for the previous acceptance, but it is documented from the very beginning that "This directory must exist"
(see 4457ba002d64d4a991b0561c5be69a8c61b2b828). We removed catching OSError
in Django 2.2, but it was untested and undocumented behavior.
Thanks for this report, I agree that it's a regression in a0ca4b5694f43c63ea13ba6908eff2bd53ee7ebb. We should restore catching
OSError
. Documentation issue is not a regression so I sent a separate PR with fix.Reproduced at fc2b1cc926e34041953738e58fa6ad3053059b22.