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

Add more informative error message when opening notebook and disk is full #1444

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions jupyter_server/base/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
from jupyter_server.utils import (
ensure_async,
filefind,
is_sqlite_disk_full_error,
url_escape,
url_is_absolute,
url_path_join,
Expand Down Expand Up @@ -765,6 +766,9 @@ def write_error(self, status_code: int, **kwargs: Any) -> None:
if isinstance(e, HTTPError):
reply["message"] = e.log_message or message
reply["reason"] = e.reason
elif is_sqlite_disk_full_error(e):
reply["message"] = "Disk is full"
reply["reason"] = str(e)
else:
reply["message"] = "Unhandled error"
reply["reason"] = None
Expand Down
9 changes: 9 additions & 0 deletions jupyter_server/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -433,3 +433,12 @@ class JupyterServerAuthWarning(RuntimeWarning):
Intended for filtering out expected warnings in tests, including
downstream tests, rather than for users to silence this warning.
"""


def is_sqlite_disk_full_error(e: Exception) -> bool:
try:
import sqlite3

return isinstance(e, sqlite3.OperationalError) and e.sqlite_errorcode == sqlite3.SQLITE_FULL # type: ignore[attr-defined]
except (AttributeError, ImportError) as e:
return "database or disk is full" in str(e)
Loading