Skip to content

Add error view for error handling and error view testing #11263

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Apr 10, 2024

Conversation

agjohnson
Copy link
Contributor

I was having trouble testing error views and templates locally and found
at some point we added a /500 for testing the 500 error page. I
expanded on this to create a view that could emit any error status code
and relevant template. Afterwards, it seemed like we had a few redundant
views doing similar things, so I expanded the dashboard error handlers
to all use the same view as well.

Changes here are:

  • When using the new dashboard, dashboard error templates are in the
    /errors/dashboard/ template path. There will be a duplicate set of
    templates for Proxito errors and documentation errors, in
    /errors/proxito/ eventually.
  • This swaps out the URL handler500, and defines the missing handlers
    in the URL module. Mostly, this loads these error templates from a
    more structured path instead of top level /404.html templates.
  • Adds a debug view/URL for testing arbitrary error views/templates in
    debug mode.

This does not touch proxito error pages yet.

I was having trouble testing error views and templates locally and found
at some point we added a `/500` for testing the 500 error page. I
expanded on this to create a view that could emit any error status code
and relevant template. Afterwards, it seemed like we had a few redundant
views doing similar things, so I expanded the dashboard error handlers
to all use the same view as well.

Changes here are:

- When using the new dashboard, dashboard error templates are in the
  `/errors/dashboard/` template path. There will be a duplicate set of
  templates for Proxito errors and documentation errors, in
  `/errors/proxito/` eventually.
- This swaps out the URL `handler500`, and defines the missing handlers
  in the URL module. Mostly, this loads these error templates from a
  more structured path instead of top level `/404.html` templates.
- Adds a debug view/URL for testing arbitrary error views/templates in
  debug mode.

This does not touch proxito error pages yet.
@agjohnson agjohnson requested a review from a team as a code owner April 3, 2024 23:48
@agjohnson agjohnson requested a review from humitos April 3, 2024 23:48
Copy link
Member

@humitos humitos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great!

This is just the dashboard response view for spam projects.
@agjohnson
Copy link
Contributor Author

The test failure is due to the default handler giving up on loading a missing template:

https://github.com/django/django/blob/main/django/views/defaults.py#L139-L150

I'll see about adding this or just add a 403 template, it probably doesn't matter as we're already not giving a templated response in these views.

The 401 template has copy closer to 403 already, and I don't believe we
are emitting a templated 403 response anywhere either.
@agjohnson agjohnson requested a review from a team as a code owner April 4, 2024 20:27
@agjohnson
Copy link
Contributor Author

I did indeed just symlink the 401 to 403 template for now. I'm guessing if anyone is replicating the test case responses in real life, they are just getting the default, empty, Django 403 reponse. The 401 template wasn't entirely a great fit, but it's good enough because of all of this.

Same on https://github.com/readthedocs/readthedocs-corporate/pull/1767

@agjohnson
Copy link
Contributor Author

Docs failures are unrelated, I'll merge this now.

@agjohnson agjohnson merged commit 23330ff into main Apr 10, 2024
5 of 7 checks passed
@agjohnson agjohnson deleted the agj/error-handling-dashboard branch April 10, 2024 18:04
@humitos
Copy link
Member

humitos commented Apr 11, 2024

This is why the fancy 404 pages weren't working on production yet? 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants