fix: normalize paths in file router to prevent HTTPException with dotdot paths#8425
Merged
mscolnick merged 1 commit intomarimo-team:mainfrom Feb 23, 2026
Merged
Conversation
…dot paths
When file paths contain '..' components (e.g., from os.path.join with
'..'), _allowed_paths stored the un-normalized absolute path while
resolve_file_path() normalized it via os.path.normpath(). This mismatch
caused HTTPException('File not found') during SessionManager
initialization for the create_asgi_app() / FastAPI integration.
Normalize paths consistently using normalize_path() when building
_allowed_paths and in register_allowed_file().
Fixes marimo-team#8414
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
I have read the CLA Document and I hereby sign the CLA You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot. |
Contributor
Author
|
I have read the CLA Document and I hereby sign the CLA |
mscolnick
approved these changes
Feb 22, 2026
|
Thank you for looking at this issue and doing a PR, much appreciated. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes a bug where
create_asgi_app()fails withHTTPExceptionwhen file paths contain..components.Problem: When using
os.path.join(os.path.dirname(__file__), "..", "..", "ui")(as the FastAPI example does),_allowed_pathsstored the un-normalized absolute path (preserving..), whileresolve_file_path()normalized it viaos.path.normpath(). This mismatch causedHTTPException('File not found')duringSessionManagerinitialization.Fix: Normalize paths consistently using
normalize_path()when building_allowed_pathsinListOfFilesAppFileRouter.__init__and inregister_allowed_file().Fixes #8414
Test Plan
test_list_of_files_resolves_dotdot_in_paththat creates a file router with a..path and verifiesresolve_file_path()succeedstest_file_router.pypass