Skip to content
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

404's should display an error page and not redirect #663

Open
brassy-endomorph opened this issue Oct 8, 2024 · 0 comments
Open

404's should display an error page and not redirect #663

brassy-endomorph opened this issue Oct 8, 2024 · 0 comments

Comments

@brassy-endomorph
Copy link
Collaborator

Is your feature request related to a problem? Please describe.

When a user access a resource that isn't found (not authorized, missing, whatever), they should land on an actual missing page that displays a generic "not found" error message whose status code is 404. No flashed message should be displayed.

Why?

We have some non-standard code that has already led me to confusion as to why abort(404) (a typical pattern) wasn't working as expected.

Affected endpoint:

hushline/hushline/routes.py

Lines 553 to 562 in 4552cb0

@app.route("/info")
def personal_server_info() -> Response:
if app.config.get("IS_PERSONAL_SERVER"):
ip_address = get_ip_address()
return make_response(
render_template(
"personal_server_info.html", is_personal_server=True, ip_address=ip_address
)
)
return Response(status=404)

Affected error handler:

@app.errorhandler(404)
def page_not_found(e: Exception) -> Response:
flash("⛓️‍💥 That page doesn't exist.", "warning")
return redirect(url_for("index"))

Also, this will make it possible for tests to check that a missing/unauthorized entity actually returns 404 (a clear sign of missing) instead of redirects to / and then doesn't have some heading (User 123) present in the response body.

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

No branches or pull requests

1 participant