MAINT Support relative blob paths in AzureBlobStorageIO#1478
Merged
romanlutz merged 3 commits intomicrosoft:mainfrom Apr 12, 2026
Merged
MAINT Support relative blob paths in AzureBlobStorageIO#1478romanlutz merged 3 commits intomicrosoft:mainfrom
romanlutz merged 3 commits intomicrosoft:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Updates AzureBlobStorageIO so callers can pass either a full Azure Blob URL or a relative blob path (within the configured container) consistently across blob operations.
Changes:
- Added a
_resolve_blob_name()helper to accept either full blob URLs or relative blob paths. - Updated
read_file(),write_file(),path_exists(), andis_file()to use the helper instead of requiring URL parsing. - Added regression tests for relative-path handling in
read_file()andpath_exists().
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
pyrit/models/storage_io.py |
Adds blob-name resolution helper and applies it across Azure blob operations to support relative paths. |
tests/unit/models/test_storage_io.py |
Adds unit tests validating relative-path behavior for read_file() and path_exists(). |
You can also share your feedback on Copilot code review. Take the survey.
…ths, expand tests - Replace double urlparse with try/except around parse_blob_url - Normalize backslashes to forward slashes for Windows Path safety - Update write_file() docstring to document relative path support - Add comment explaining intentional container name discard - Add missing tests for write_file and is_file with relative paths - Add edge case tests for _resolve_blob_name (backslashes, Path objects, etc.) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
romanlutz
approved these changes
Apr 12, 2026
Contributor
romanlutz
left a comment
There was a problem hiding this comment.
It's a theoretical problem since we're not using relative blob paths but nevertheless not a bad idea.
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
This updates
AzureBlobStorageIOso that relative blob paths are handled consistently across blob operations.Problem
Several
AzureBlobStorageIOmethods document or imply support for either:In particular,
read_file()explicitly documents relative-path support. However, the implementation always routed the input throughparse_blob_url(), which only accepts full URLs and raisesValueErrorfor relative paths.That means calls such as:
fail immediately with
ValueError("Invalid blob URL")even though the method contract says the relative path should be used as-is.The same issue also affects
path_exists()andis_file(), and it unnecessarily constrainswrite_file()to URL-only inputs as well.Fix
_resolve_blob_namehelper that:parse_blob_url), orparse_blob_urlto avoid redundanturlparsecallsPathobjects created on Windows produce valid blob namesread_file(),write_file(),path_exists(), andis_file()write_file()docstring to document that both full URLs and relative paths are accepted_resolve_blob_namedocstringThis keeps the existing full-URL behavior intact while making the relative-path behavior match the documented API.
Tests
Added regression coverage for relative-path handling in all four affected methods:
read_file()write_file()path_exists()is_file()Added edge case tests for
_resolve_blob_name:Pathobject handlingValidation command:
Validation result: