Skip to content

Adds platform path handling to sandbox file imports#2064

Merged
Spoffy merged 1 commit intomainfrom
spoffy/resolve-platform-import-paths
Jan 22, 2026
Merged

Adds platform path handling to sandbox file imports#2064
Spoffy merged 1 commit intomainfrom
spoffy/resolve-platform-import-paths

Conversation

@Spoffy
Copy link
Contributor

@Spoffy Spoffy commented Jan 22, 2026

Context

Pyodide's sandbox security was improved by changing it to copy import folders into the sandbox, rather than mounting the host's filesystem directly.

This resulted in Grist's file imports breaking on Windows, due to the Pyodide sandbox using POSIX-style paths and the Grist node process using Windows-style paths.

The node process would produce import paths similar to my_temp_dir\my_file_to_import.csv, which Pyodide would interpret as a file name (rather than a directory and a file).

Proposed solution

This adds "pathFlavor" to the FileSource object passed to the sandbox, describing if the path is Windows or POSIX formatted. This allows the sandbox to parse and re-format the path as needed for the sandbox's filesystem.

Related issues

gristlabs/grist-desktop#101

Has this been tested?

This fix has been tested on Windows with a custom Grist Desktop build, but not automatically as core doesn't have any Windows test runners configured.

Copy link
Member

@paulfitz paulfitz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @Spoffy !


# Parse the incoming path using the appropriate pathlib class
if path_flavor == "windows":
incoming_path = PureWindowsPath(file_source_path)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks to be okay to use in python versions >= about 3.4 so all the python versions we care about. Good!

@Spoffy Spoffy merged commit 3d6c384 into main Jan 22, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants