Skip to content

FIX: Reject a blob URL without a container instead of raising IndexError - #3329

Merged
Roman Lutz (romanlutz) merged 2 commits into
microsoft:mainfrom
feiiiiii5:fix/azure-blob-url-invalid
Oct 19, 2026
Merged

Roman Lutz (romanlutz) merged 2 commits into
microsoft:mainfrom
feiiiiii5:fix/azure-blob-url-invalid

Conversation

@feiiiiii5

Copy link
Copy Markdown
Contributor

Description

AzureBlobStorageIO.parse_blob_url documents ValueError: If file_path is not a valid blob URL, but only the missing-scheme / missing-host case raises it. A URL with a scheme and host and no path (https://account.blob.core.windows.net) reached parsed_url.path.split("/")[1] and raised IndexError: list index out of range, and a URL ending in / produced an empty container name instead.

_resolve_blob_name catches ValueError only, so its fallback to treating the input as a local path never ran for either input, and every entry point that goes through it (read_file_async, write_file_async, path_exists_async, delete_file_async, is_file_async) inherited the IndexError.

The path is now checked the same way the scheme and host are: a container segment that is missing or empty raises ValueError("Invalid blob URL").

Tests and Documentation

Test: pytest tests/unit/memory/storage/test_storage.py -q -k "without_container_path or empty_container_name or without_container_falls_back" fails on main — IndexError at storage.py:309 for two of them and DID NOT RAISE for the third — and passes here. pytest tests/unit/memory/storage -q → 128 passed; the wider set (storage + test_azure_sql_memory + the Azure Blob target) → 235 passed, 1 skipped. ruff check and ruff format --check clean; ty check reports the same single pre-existing diagnostic at storage.py:97 before and after.

No documentation change beyond what the docstring already promised.

parse_blob_url documents ValueError for an invalid blob URL, but a URL with a scheme and host and no path raised IndexError, and a trailing slash produced an empty container name. _resolve_blob_name only catches ValueError, so its fallback never ran for those inputs.
@romanlutz
Roman Lutz (romanlutz) merged commit a8afb05 into microsoft:main Oct 19, 2026
64 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