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.
Python artificial-intelligencedagdata-sciencedata-visualizationdataflowdeveloper-toolsmachine-learningnotebookspipelinepythonreactivesqlweb-app
fix: don't override user if it is None (#3820)
Myles Scolnick34f98e7b30b2
diff --git a/marimo/_server/api/auth.py b/marimo/_server/api/auth.pyindex fc04c92ce3..ee565a2465 100644--- a/marimo/_server/api/auth.py+++ b/marimo/_server/api/auth.py@@ -233,7 +233,8 @@ class CustomAuthenticationMiddleware(AuthenticationMiddleware):# Get the developer-defined that we saved earlierdeveloper_defined_user = scope.get(self.KEY)# Store it back in the scope- scope["user"] = developer_defined_user+ if developer_defined_user is not None:+ scope["user"] = developer_defined_userawait app(scope, receive, send)super().__init__(wrapped_app, *args, **kwargs)diff --git a/tests/_server/api/endpoints/test_execution.py b/tests/_server/api/endpoints/test_execution.pyindex a053230eb5..87f0752d46 100644--- a/tests/_server/api/endpoints/test_execution.py+++ b/tests/_server/api/endpoints/test_execution.py@@ -200,7 +200,7 @@ class TestExecutionRoutes_EditMode:for header in app_meta_response["headers"].keys())# Check user is False- assert app_meta_response["user"] is False+ assert app_meta_response["user"] is Trueclass TestExecutionRoutes_RunMode:diff --git a/tests/_server/api/test_auth.py b/tests/_server/api/test_auth.pyindex da6c721ba1..aa74bd33a8 100644--- a/tests/_server/api/test_auth.py+++ b/tests/_server/api/test_auth.py@@ -179,7 +179,8 @@ async def test_custom_auth_middleware_without_user():async def test_app(scope: Any, receive: Any, send: Any) -> None:del receive, send- assert scope["user"] is None+ # Fallbacks to SimpleUser("user")+ assert scope["user"].username == "user"middleware = CustomAuthenticationMiddleware(test_app, backend=AuthBackend(should_authenticate=False)