Skip to content

Windows: LocalStorage file:// URLs with an empty path - #56

Merged
sambles merged 1 commit into
mainfrom
fix/windows-local-storage-url
Nov 19, 2026
Merged

sambles merged 1 commit into
mainfrom
fix/windows-local-storage-url

Conversation

@Ha-Ree

@Ha-Ree Ha-Ree commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Part of OasisLMF/OasisLMF#2305

LocalStorage.get_storage_url returned f"file://{Path(root_dir, filename)}". On Windows that is file://C:\...: C:\... is parsed as the URL's host and the path is empty, so reading an OED file given as a string (pandas read_csv through ods_tools) fails with URLError (WinError 3).

Changes

  • path_to_file_url: the path is made absolute and written in posix form after a leading /, giving file:///C:/... on Windows. POSIX absolute paths give exactly the same URL as before (file:///abs/path). A relative root_dir (the default "") used to give file://rel/path, where rel is the host; it now gives the absolute URL. No percent-encoding, as before.
  • file_url_to_path: the inverse, used by the pyarrow reader instead of uri.replace('file://', ''), which would have left /C:/... on Windows.

Tests

  • tests/filestorage/test_local.py: Windows path to URL and back (checked with nturl2path), POSIX URL unchanged, and a LocalStorage URL with and without root_dir read by pd.read_csv.
  • pytest tests/filestorage/test_local.py tests/df_reader --ignore=tests/df_reader/test_geo.py: 38 passed, 9 skipped (33 in df_reader, unchanged from main; 5 in test_local.py, 3 of them new). test_geo.py cannot be collected here (no dask), unrelated.

OasisLMF also stops sending local OED files to ods_tools as strings, so it no longer depends on this fix.

🤖 Generated with Claude Code

get_storage_url returned f"file://{path}", which on Windows is
file://C:\..., parsed as host 'C:\...' with an empty path, so pandas (and
ods_tools through it) failed with URLError (WinError 3). The path is now made
absolute and written in posix form after a leading '/': file:///C:/... on
Windows, file:///abs/path unchanged on POSIX (a relative root_dir no longer
gives the host-only file://rel/path). The pyarrow reader turns the URL back
into a path with the matching file_url_to_path.

Part of OasisLMF/OasisLMF#2305

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@sambles
sambles merged commit aec9121 into main Nov 19, 2026
4 checks passed
@sambles
sambles deleted the fix/windows-local-storage-url branch November 19, 2026 16:22
@github-actions github-actions Bot mentioned this pull request Nov 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants