Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

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

Đang mở Phù hợp với người mới
#3,495 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 2 ngày

@ShivamSharma43 đang làm issue này rồi.

Từ ngày 23/10/2026.

  • #3497 của @ShivamSharma43 — đang mở

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
82/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
azure, python
Lĩnh vực
backend, cloud

Hướng nghiên cứu

Đọc AzureBlobStorageTarget._send_prompt_to_target_async và _parse_url, được issue xác định là các điểm tạo URL và phân tích quá trình tải lên. Tái hiện sự cố với các trường hợp được cung cấp cho URL container kết thúc bằng / và URL có tiền tố thư mục. Hoàn thành khi cả tên blob đã tải lên và các URL trả về đều khớp với kết quả mong đợi, không có dấu gạch chéo kép.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Describe the bug

AzureBlobStorageTarget._send_prompt_to_target_async builds the returned URL by appending to the configured container URL:

blob_url = self._container_url + "/" + file_name

When container_url (or AZURE_STORAGE_ACCOUNT_CONTAINER_URL) ends with /, for example https://acct.blob.core.windows.net/xpia/, the URL gets // before the file name. The upload goes through _parse_url, which ignores the empty segment, so the blob is uploaded as doc.txt. The returned URL .../xpia//doc.txt names a blob /doc.txt, which does not exist, so anything that uses the returned URL (for example the XPIA workflows) points at a missing blob.

With a folder prefix and a trailing slash (.../xpia/folder/), _parse_url returns the prefix folder/, so the blob itself is uploaded as folder//doc.txt instead of folder/doc.txt.

Steps/Code to Reproduce
import asyncio
from unittest.mock import AsyncMock, MagicMock, patch

from pyrit.setup import IN_MEMORY, initialize_pyrit_async


async def main():
    await initialize_pyrit_async(memory_db_type=IN_MEMORY)

    from pyrit.models import Message, MessagePiece
    from pyrit.prompt_target import AzureBlobStorageTarget

    for container_url in ["https://acct.blob.core.windows.net/xpia/", "https://acct.blob.core.windows.net/xpia/folder/"]:
        target = AzureBlobStorageTarget(container_url=container_url, sas_token="sv=test")
        client = AsyncMock()
        client.get_blob_client = MagicMock(return_value=AsyncMock(exists=AsyncMock(return_value=False)))
        piece = MessagePiece(role="user", original_value="payload", prompt_metadata={"file_name": "doc.txt"})

        with patch("azure.storage.blob.aio.ContainerClient.from_container_url", return_value=client):
            response = await target.send_prompt_async(message=Message(message_pieces=[piece]))

        print("container_url:", container_url)
        print("  uploaded blob:", client.get_blob_client.call_args.kwargs["blob"])
        print("  returned URL :", response[0].get_value())


asyncio.run(main())
Expected Results

The trailing slash makes no difference:

container_url: https://acct.blob.core.windows.net/xpia/
  uploaded blob: doc.txt
  returned URL : https://acct.blob.core.windows.net/xpia/doc.txt
container_url: https://acct.blob.core.windows.net/xpia/folder/
  uploaded blob: folder/doc.txt
  returned URL : https://acct.blob.core.windows.net/xpia/folder/doc.txt
Actual Results

The returned URL does not match the uploaded blob, and the prefixed blob gets an empty path segment:

container_url: https://acct.blob.core.windows.net/xpia/
  uploaded blob: doc.txt
  returned URL : https://acct.blob.core.windows.net/xpia//doc.txt
container_url: https://acct.blob.core.windows.net/xpia/folder/
  uploaded blob: folder//doc.txt
  returned URL : https://acct.blob.core.windows.net/xpia/folder//doc.txt
Screenshots

N/A

Versions
  • OS: Windows 11
  • Python version: 3.11.9
  • PyRIT version: installed from main (eeb9ba9d) in editable mode
Ngôn ngữ chính
Python
Star
4.6k
Fork
962
Merge trung bình
2 ngày 13 giờ
Pull request đã merge (30 ngày)
423

Chuẩn bị môi trường

Mở trong Codespaces

Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.

  • Không có Dockerfile hay tệp Docker Compose
  • Có mẫu pull request
  • Không có hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của microsoft/PyRIT

Tất cả issue của microsoft/PyRIT

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.