[Django] #28172: Non-existent arg passed to template filter raises VariableDoesNotExist (alternative solution)

25 views
Skip to first unread message

Django

unread,
May 4, 2017, 11:00:29 AM5/4/17
to django-...@googlegroups.com
#28172: Non-existent arg passed to template filter raises VariableDoesNotExist
(alternative solution)
-------------------------------------------+------------------------
Reporter: Vlastimil Zíma | Owner: nobody
Type: Bug | Status: new
Component: Template system | Version: master
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------------+------------------------
I'd like to fix the error reported in #13167. The main bug

{{{
#!python
from django.template import Context, Template
Template('{{ foo|default:notreal }}').render(Context({'foo': ''}))
}}}

still raises `VariableDoesNotExist` exception, which is completely
unexpected from templates, as noted in closing comment
ticket:13167#comment:20. I took me more than an hour before I found out
how did it make the server error I investigated.

I know the original ticket was closed as wontfix, but I understood it was
due to the effect the proposed change would have on `if` tag. But there's
another way - capture the exception in `VariableNode` the similar way
`UnicodeDecodeError` is silenced. If I understood the code correctly, that
would solve the problem for all template filters, but left template tags
intact.

--
Ticket URL: <https://code.djangoproject.com/ticket/28172>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
May 31, 2017, 11:07:23 AM5/31/17
to django-...@googlegroups.com
#28172: Prevent nonexistent template filter arguments from raising
VariableDoesNotExist
---------------------------------+-----------------------------------------

Reporter: Vlastimil Zíma | Owner: nobody
Type: Bug | Status: new
Component: Template system | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Someday/Maybe

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+-----------------------------------------
Changes (by Tim Graham):

* stage: Unreviewed => Someday/Maybe


Comment:

I understand the "template errors don't raise exceptions" philosophy,
however, I think changing the current behavior would be more error prone
(e.g. typos in variable names go more easily undetected). I've started a
[https://groups.google.com/d/topic/django-
developers/VPzVbQRSoj4/discussion django-developers thread] to get other
opinions.

--
Ticket URL: <https://code.djangoproject.com/ticket/28172#comment:1>

Django

unread,
Jun 19, 2017, 1:23:38 PM6/19/17
to django-...@googlegroups.com
#28172: Prevent nonexistent template filter arguments from raising
VariableDoesNotExist
-------------------------------------+-------------------------------------
Reporter: Vlastimil Zíma | Owner: Alejandro
| Zamora Fonseca
Type: Bug | Status: assigned

Component: Template system | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Someday/Maybe
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Alejandro Zamora Fonseca):

* status: new => assigned
* owner: nobody => Alejandro Zamora Fonseca


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

Django

unread,
Jun 19, 2017, 2:03:55 PM6/19/17
to django-...@googlegroups.com
#28172: Prevent nonexistent template filter arguments from raising
VariableDoesNotExist
-------------------------------------+-------------------------------------
Reporter: Vlastimil Zíma | Owner: Alejandro
| Zamora Fonseca
Type: Bug | Status: assigned
Component: Template system | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Someday/Maybe
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Tim Graham):

Alejandro, I don't think there's consensus to make this change (hence the
ticket's Someday/Maybe status). Did you read the mailing list discussion
linked from in comment 1?

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

Django

unread,
Jun 19, 2017, 2:09:40 PM6/19/17
to django-...@googlegroups.com
#28172: Prevent nonexistent template filter arguments from raising
VariableDoesNotExist
---------------------------------+-----------------------------------------
Reporter: Vlastimil Zíma | Owner: (none)

Type: Bug | Status: new
Component: Template system | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Someday/Maybe
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+-----------------------------------------

Changes (by Alejandro Zamora Fonseca):

* status: assigned => new
* owner: Alejandro Zamora Fonseca => (none)


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

Reply all
Reply to author
Forward
0 new messages