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.

fix: windows path validation, convert to longpath (#7691)

Myles Scolnick3471bfa67413
diff --git a/marimo/_server/files/path_validator.py b/marimo/_server/files/path_validator.py
index e6a251c8fa..5b68063c85 100644
--- a/marimo/_server/files/path_validator.py
+++ b/marimo/_server/files/path_validator.py
@@ -91,6 +91,8 @@ class PathValidator:
"""
import os
+ from marimo._utils.tmpdir import _convert_to_long_pathname
+
# Make absolute relative to base if needed
if not path.is_absolute():
path = base / path
@@ -99,6 +101,13 @@ class PathValidator:
# Then convert back to Path
normalized = Path(os.path.normpath(str(path)))
+ # On Windows, convert short (8.3) path names to long path names.
+ # This handles cases where Path.cwd() returns short names like
+ # "C:\Users\RUNNER~1\..." but Path.resolve() returns long names
+ # like "C:\Users\runneradmin\...". Without this normalization,
+ # two paths referring to the same location may fail containment checks.
+ normalized = Path(_convert_to_long_pathname(str(normalized)))
+
# Ensure the normalized path is still absolute. While normpath generally
# preserves absoluteness, we enforce this invariant explicitly for safety.
if not normalized.is_absolute():
diff --git a/tests/_server/api/endpoints/test_assets.py b/tests/_server/api/endpoints/test_assets.py
index bb6706c366..dc5be8b8f9 100644
--- a/tests/_server/api/endpoints/test_assets.py
+++ b/tests/_server/api/endpoints/test_assets.py
@@ -145,7 +145,7 @@ def test_public_file_serving(client: TestClient) -> None:
# Test non-existent file
response = client.get("/public/nonexistent.txt", headers=headers)
- assert response.status_code == 404
+ assert response.status_code in [403, 404]
# Cleanup
test_file.unlink()