Opened 11 years ago
Closed 17 months ago
#22055 closed Cleanup/optimization (wontfix)
404 page does not display stack trace when Resolver404 is raised from a view
Reported by: | Grzegorz Nosek | Owned by: | Andrew Northall |
---|---|---|---|
Component: | Core (URLs) | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | Andrew Northall | Triage Stage: | Unreviewed |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Related to #18373, the 404 error page served when django.core.urlresolvers.resolve() fails does not contain the exception stack trace, which makes finding the failing call unnecessarily difficult.
When the resolve() call fails in a view, the error should actually be 500 (it's not the user's fault), but for backwards compatibility the response code will have to remain 404 (as discussed with Honza Kral last year).
Change History (12)
comment:1 by , 11 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:2 by , 11 years ago
comment:3 by , 11 years ago
Resolution: | → wontfix |
---|---|
Status: | assigned → closed |
comment:4 by , 11 years ago
Resolution: | wontfix |
---|---|
Status: | closed → new |
See #18373 for the use case.
If you're calling resolve('/some-url') that fails, you're not raising an Http404 explicitly. It's just a function call that fails, just like the ORM or whatever.
I agree that manually raised Http404s should not trigger the stack trace and this ticket is not about it. It's just about treating exceptions from resolve() failure just like every other exception.
IMO, the right thing to do is:
- Failing to resolve a URL from Django core -> no stack trace
- Raising Http404 from a view -> no stack trace
- Failing to resolve a URL from a view -> stack trace (and arguably 500 response code but there's backwards compatibility to worry about)
comment:5 by , 11 years ago
Triage Stage: | Unreviewed → Accepted |
---|---|
Type: | Uncategorized → Cleanup/optimization |
comment:6 by , 21 months ago
Owner: | removed |
---|---|
Status: | new → assigned |
comment:7 by , 21 months ago
Status: | assigned → new |
---|
comment:9 by , 18 months ago
Cc: | added |
---|---|
Has patch: | set |
Version: | 1.6 → dev |
Initial patch added. Keen for some feedback on the implementation. Many thanks!
comment:10 by , 18 months ago
Owner: | set to |
---|
comment:11 by , 17 months ago
I'm not sure if it's too late to propose to "unaccept" this ticket. I have read the use case, and while there is a description for a use case, that use case feels, to me, insufficient to make a strong argument to add this change of behavior in the django codebase.
My rationale is that failing to resolve an URL in a view is, indeed, semantically an "url not found" (404) result. At least in my experience, I can think of a few reasons for a failed resolve in a view such as:
- there is a spelling error in the url name or args (in which case the unit tests should caught this)
- there is a dynamic component in the url name/params that at the time of the execution evaluates to something that does not exist (this still feels like a 404 and not a 500)
- something else I'm missing?
I don't think the above justify the complexity that seems to be necessary to solve this (following PR 17007).
comment:12 by , 17 months ago
Has patch: | unset |
---|---|
Resolution: | → wontfix |
Status: | assigned → closed |
Triage Stage: | Accepted → Unreviewed |
Agreed, it's not worth adding the extra complexity. 404 is not like other exceptions and treating some 404s differently just because they don't come from the Django codebase could be confusing.
Hi,
What kind of useful information could you gain from a 404 page with a stacktrace? If you're explicitly creating a 404 exception then you want that to happen.
Could you convince this list of the usefulness in changing this behaviour, please?