Skip to content

FIX Handle a trailing slash on the AzureBlobStorageTarget container URL - #3497

Open
Shivam Sharma (ShivamSharma43) wants to merge 1 commit into
microsoft:mainfrom
ShivamSharma43:fix/blob-target-trailing-slash
Open

Shivam Sharma (ShivamSharma43) wants to merge 1 commit into
microsoft:mainfrom
ShivamSharma43:fix/blob-target-trailing-slash

Conversation

@ShivamSharma43

Copy link
Copy Markdown
Contributor

Description

Fixes #3495.

AzureBlobStorageTarget built the returned URL as self._container_url + "/" + file_name. With a container URL that ends in /, such as https://acct.blob.core.windows.net/xpia/, the URL was .../xpia//doc.txt, which names a blob /doc.txt. The blob was actually uploaded as doc.txt, so the returned URL pointed at a blob that does not exist. With a folder prefix (.../xpia/folder/), _parse_url returned the prefix folder/ and the blob itself was uploaded as folder//doc.txt.

Changes:

  • The returned URL is built from the container URL without its trailing slash.
  • _parse_url strips slashes from the blob prefix, so folder/ becomes folder and the blob is uploaded as folder/doc.txt.

URLs without a trailing slash produce the same blob path and URL as before. The stored container_url and the target identifier are unchanged.

Tests and Documentation

  • New parametrized test in tests/unit/prompt_target/target/test_prompt_target_azure_blob_storage.py: for a container URL with and without a trailing slash, and with and without a folder prefix, it checks the container client URL, the uploaded blob path and the returned URL.
  • On main the two trailing-slash cases fail; with this change all four pass.
  • pytest tests/unit/prompt_target: 1829 passed, 247 skipped.
  • ruff check, ruff format and ty check pass on the changed files.
  • No documentation changes.

🤖 Generated with Claude Code

With a container URL ending in "/", the returned blob URL had "//"
before the file name and named a blob that was never uploaded, and a
folder prefix such as "folder/" uploaded the blob as "folder//name".
Strip the trailing slash when building the returned URL and the blob
prefix.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings October 23, 2026 17:37

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

This branch has not been deployed

No deployments
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.

BUG: AzureBlobStorageTarget returns a URL with // when the container URL ends with a slash

2 participants