Skip to content

A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.

chore(ruff): handle unexpected REST cache responses (#10790)

Shahmir Varqhabf7f53101954
diff --git a/marimo/_save/stores/rest.py b/marimo/_save/stores/rest.py
index f4419422a1..5f08232d4f 100644
--- a/marimo/_save/stores/rest.py
+++ b/marimo/_save/stores/rest.py
@@ -41,7 +41,10 @@ class RestStore(Store):
if response.status >= 400 and response.status < 500:
# 400s are fine, they just mean the key doesn't exist
return None
- raise
+ LOGGER.warning(
+ "GET %s - Unexpected status: %s", url, response.status
+ )
+ return None
except urllib.error.HTTPError as e:
if e.code >= 400 and e.code < 500:
# 400s are fine, they just mean the key doesn't exist
diff --git a/pyproject.toml b/pyproject.toml
index 93548f5c86..491baafdd7 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -379,7 +379,6 @@ ignore = [
"S112", # `try`-`except`-`continue`
"PLW1509", # `subprocess` `preexec_fn` argument
"DTZ002", # `datetime.today()` called without tz
- "PLE0704", # Misplaced bare `raise`
"D421", # Property docstring should not start with a verb (preview rule)
# Restored to Ruff's default rule set in 0.16.6; enable incrementally
diff --git a/tests/_save/stores/test_rest.py b/tests/_save/stores/test_rest.py
new file mode 100644
index 0000000000..af8a0a87a9
--- /dev/null
+++ b/tests/_save/stores/test_rest.py
@@ -0,0 +1,28 @@
+# Copyright 2026 Marimo. All rights reserved.
+from __future__ import annotations
+
+from unittest.mock import MagicMock, patch
+
+from marimo._save.stores import rest
+
+
+def test_get_logs_unexpected_response_status() -> None:
+ store = rest.RestStore(
+ base_url="https://cache.example.com", api_key="test-key"
+ )
+ response = MagicMock()
+ response.status = 500
+ response.__enter__.return_value = response
+
+ with (
+ patch.object(rest.urllib.request, "urlopen", return_value=response),
+ patch.object(rest.LOGGER, "warning") as warning,
+ ):
+ result = store.get("cache-key")
+
+ assert result is None
+ warning.assert_called_once_with(
+ "GET %s - Unexpected status: %s",
+ "https://cache.example.com/cache-key",
+ 500,
+ )