Fix unbound ORM object erroring during 500 handler.

The 500 fixed in 71738b05fc revealed that attempting to access g.v at
all during an error handler can potentially cause its own error.
In particular, html_head L111 accessing v.themecolor errored because
we roll back the database session during 500 handling. There's no good
solution other than specifically not passing v to 500 error pages.

However, in the interest of failing fast and ensuring error handlers
always complete, we instead go back to the previous behavior of not
treating users as logged in for error pages.
master
Snakes 2022-12-01 17:24:41 -05:00
parent 71738b05fc
commit 27506b36c2
Signed by: Snakes
GPG Key ID: E745A82778055C7E
1 changed files with 1 additions and 3 deletions

View File

@ -36,9 +36,7 @@ def error(e):
if request.headers.get("Authorization") or request.headers.get("xhr"): if request.headers.get("Authorization") or request.headers.get("xhr"):
return {"error": title, "code": e.code, "description": msg, "details": details}, e.code return {"error": title, "code": e.code, "description": msg, "details": details}, e.code
img = ERROR_MARSEYS.get(e.code, 'marseyl') img = ERROR_MARSEYS.get(e.code, 'marseyl')
if hasattr(g, "v"): v = g.v return render_template('errors/error.html', title=title, msg=msg, details=details, img=img), e.code
else: v = None
return render_template('errors/error.html', title=title, msg=msg, details=details, img=img, v=v), e.code
@app.errorhandler(401) @app.errorhandler(401)
def error_401(e): def error_401(e):