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

In jupyter-websocket mode, base handler tries to use jinja to render an error #71

Closed
parente opened this issue Jan 13, 2016 · 2 comments
Assignees
Milestone

Comments

@parente
Copy link
Contributor

parente commented Jan 13, 2016

The handler from notebook is overriding http://tornado.readthedocs.org/en/latest/web.html#tornado.web.RequestHandler.write_error and using jinja to render a pretty HTML page for a user. We should probably point it back to the most base class version (http://tornado.readthedocs.org/en/latest/_modules/tornado/web.html#RequestHandler.write_error) for consistency with notebook-http mode. That or consistently return no body or a JSON body like {"status" : same_int_as_http_status_code, "message": "whatever we can"}

ERROR:tornado.application:Uncaught exception in write_error
Traceback (most recent call last):
  File "/usr/local/lib/python3.4/dist-packages/tornado/web.py", line 1443, in _execute
    result = method(*self.path_args, **self.path_kwargs)
  File "/usr/local/lib/python3.4/dist-packages/kernel_gateway/services/kernels/handlers.py", line 31, in get
    raise tornado.web.HTTPError(404, 'Not Found')
tornado.web.HTTPError: HTTP 404: Not Found (Not Found)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.4/dist-packages/tornado/web.py", line 974, in send_error
    self.write_error(status_code, **kwargs)
  File "/usr/local/lib/python3.4/dist-packages/notebook/base/handlers.py", line 364, in write_error
    html = self.render_template('%s.html' % status_code, **ns)
  File "/usr/local/lib/python3.4/dist-packages/notebook/base/handlers.py", line 302, in render_template
    template = self.get_template(name)
  File "/usr/local/lib/python3.4/dist-packages/notebook/base/handlers.py", line 298, in get_template
    return self.settings['jinja2_env'].get_template(name)
KeyError: 'jinja2_env'
@nitind
Copy link
Collaborator

nitind commented Jan 14, 2016

I'll take care of this.

@odovad
Copy link

odovad commented Mar 14, 2022

@nitind @parente I think I encountered a similar issue :

tornado.application - ERROR - Uncaught exception in write_error
Traceback (most recent call last):
  File "/opt/conda/lib/python3.8/site-packages/tornado/web.py", line 1681, in _execute
    result = self.prepare()
  File "/opt/conda/lib/python3.8/site-packages/jupyter_server/base/handlers.py", line 507, in prepare
    raise web.HTTPError(403)
tornado.web.HTTPError: HTTP 403: Forbidden

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/conda/lib/python3.8/site-packages/tornado/web.py", line 1217, in send_error
    self.write_error(status_code, **kwargs)
  File "/opt/conda/lib/python3.8/site-packages/jupyter_server/base/handlers.py", line 590, in write_error
    html = self.render_template("%s.html" % status_code, **ns)
  File "/opt/conda/lib/python3.8/site-packages/jupyter_server/base/handlers.py", line 520, in render_template
    template = self.get_template(name)
  File "/opt/conda/lib/python3.8/site-packages/jupyter_server/base/handlers.py", line 516, in get_template
    return self.settings["jinja2_env"].get_template(name)
KeyError: 'jinja2_env'

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

3 participants