Hi, I have a process which spins up a jupyter server to be able to ping the host for a health check. My environment has jupyter_server 2.x.x and notebook 7.x.x. When starting up, I’m seeing the following issue:
Exception: You must define the ‘cookie_secret’ setting in your application to use secure cookies
500 GET /sagemaker/internal/agent/health/ping?notebookInstanceArn=arn%3Aaws%3Asagemaker%3Aus-west-2%3A572490035234%3Anotebook-instance%2Fburner-daftary-1727811391 (10.1.56.150) 1.61ms
Uncaught exception GET /sagemaker/internal/agent/health/ping?notebookInstanceArn=arn%3Aaws%3Asagemaker%3Aus-west-2%3A572490035234%3Anotebook-instance%2Fburner-daftary-1727811391 (10.1.101.7)
HTTPServerRequest(protocol=‘https’, host=‘10.0.118.180:18443’, method=‘GET’, uri=‘/sagemaker/internal/agent/health/ping?notebookInstanceArn=arn%3Aaws%3Asagemaker%3Aus-west-2%3A572490035234%3Anotebook-instance%2Fburner-daftary-1727811391’, version=‘HTTP/1.1’, remote_ip=‘10.1.101.7’)
Traceback (most recent call last):
File “/home/nbiagent-user/miniconda/lib/python3.10/site-packages/tornado/web.py”, line 1769, in _execute
result = await result # type: ignore
File “/home/nbiagent-user/miniconda/lib/python3.10/site-packages/jupyter_server/base/handlers.py”, line 751, in prepare
await super().prepare()
File “/home/nbiagent-user/miniconda/lib/python3.10/site-packages/jupyter_server/base/handlers.py”, line 623, in prepare
_user = await _user
File “/home/nbiagent-user/miniconda/lib/python3.10/site-packages/jupyter_server/auth/identity.py”, line 236, in _get_user
_cookie_user = self.get_user_cookie(handler)
File “/home/nbiagent-user/miniconda/lib/python3.10/site-packages/jupyter_server/auth/identity.py”, line 396, in get_user_cookie
_user_cookie = handler.get_secure_cookie(
File “/home/nbiagent-user/miniconda/lib/python3.10/site-packages/tornado/web.py”, line 840, in get_signed_cookie
self.require_setting(“cookie_secret”, “secure cookies”)
File “/home/nbiagent-user/miniconda/lib/python3.10/site-packages/tornado/web.py”, line 1673, in require_setting
raise Exception(
Exception: You must define the ‘cookie_secret’ setting in your application to use secure cookies
500 GET /sagemaker/internal/agent/health/ping?notebookInstanceArn=arn%3Aaws%3Asagemaker%3Aus-west-2%3A572490035234%3Anotebook-instance%2Fburner-daftary-1727811391 (10.1.101.7) 1.58ms
I updated my jupyter_server_config file as well
c.ServerApp.kernel_spec_manager_class=‘environment_kernels.EnvironmentKernelSpecManager’
c.ServerApp.login_handler_class=‘sagemaker_nbi_agent.jupyter_overrides.login_handler.SageMakerNotebookLoginHandler’
c.EnvironmentKernelSpecManager.blacklist_envs=[‘conda_jupytersystemenv’, ‘conda_anaconda3’, ‘conda_r’, ‘conda_r_r’]
c.EnvironmentKernelSpecManager.display_name_template=‘{}’
c.KernelSpecManager.ensure_native_kernel=False
c.ServerApp.cookie_secret = b’b32334eb2da874d39618063e1c387743c9ab1b88a4fe9b50cd0bcdfd87f97563’
c.ServerApp.tornado_settings={ ‘headers’: { ‘Content-Security-Policy’: “object-src ‘self’; base-uri ‘self’; upgrade-insecure-requests; frame-ancestors ‘self’; report-uri /workspace/api/security/csp-report” } }
When I try doing jupyter server --show-config, it shows Writing Jupyter server cookie to <some_path>
The value in that path is different from the value I see in my config file. Any help is appreciated! Also, note that this issue does not happen with notebook 6.x.x