FileAttachment.content_bytes does not return b64-encoded content.
還沒有人認領這個 Issue。
評估
研究方向
從 FileAttachment 模型的 content_bytes 欄位以及重現中的附件擷取呼叫開始。比較 SDK 版本 1.58.0 和 1.60.0 之間的行為,然後對擷取到的附件執行提供的 b64decode 驗證。完成的標準是:如描述所述,content_bytes 可以在 validate=True 的情況下傳遞給 b64decode。
由索引模型根據 Issue 內容生成。
描述
Describe the bug
On attempt to b64decode the content_bytes of a file attachment the following error occurs:
binascii.Error: Only base64 data is allowed
The same test provided below passes with msgraph-sdk <= 1.58.0
The code comments still suggest b64-encoded content:
# The base64-encoded contents of the file. content_bytes: Optional[bytes] = None
Expected behavior
FileAttachment.content_bytes returns b64-encoded data.
How to reproduce
from base64 import b64decode
from typing import cast
from azure.core.credentials import TokenCredential
from azure.identity import ClientSecretCredential
from msgraph import GraphServiceClient
from msgraph.generated.models.attachment import Attachment
from msgraph.generated.models.file_attachment import FileAttachment
from settings import settings
credentials = cast(
TokenCredential,
ClientSecretCredential(
tenant_id=settings().microsoft_graph_tenant_id,
client_id=settings().microsoft_graph_client_id,
client_secret=settings().microsoft_graph_client_secret,
),
)
scopes = ["https://graph.microsoft.com/.default"]
client = GraphServiceClient(credentials, scopes)
async def get_mail_attachments(
mailbox: str, mail_id: str
) -> list[Attachment]:
response = (
await client.users.by_user_id(mailbox)
.messages.by_message_id(mail_id)
.attachments.get()
)
attachments: list[Attachment] = response.value or []
return attachments
async def test_attachments():
attachments = await get_mail_attachments("my-mailbox", "my-mail-id")
assert len(attachments) >= 1
first_attachment = attachments[0]
assert isinstance(first_attachment, FileAttachment)
b64decode(first_attachment.content_bytes, validate=True)
SDK Version
1.60.0
Latest version known to work for scenario above?
1.58.0
Known Workarounds
No response
Debug output
Click to expand log
```</details>
### Configuration
_No response_
### Other information
_No response_
- 主要語言
- Python
- 星號
- 632
- 分支
- 96
- 平均合併
- 15 小時 20 分鐘
- 30 天內合併 PR
- 3
環境準備
在瀏覽器裡用你自己的 GitHub 帳號啟動這個專案的開發容器。
- 沒有 Dockerfile 或 Docker Compose 檔案
- 沒有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
microsoftgraph/msgraph-sdk-python 的其他 Issue
-
status:waiting-for-triage type:bug
難度 1/5 1 小時以內 新手友好度 90/100
microsoftgraph/msgraph-sdk-python#1570 ·
-
status:waiting-for-triage type:bug
難度 2/5 1-3 小時 新手友好度 75/100
microsoftgraph/msgraph-sdk-python#1563 ·
-
Needs: Attention :wave: type:bug
難度 2/5 1-3 小時 新手友好度 62/100
microsoftgraph/msgraph-sdk-python#1287 · 2 則留言 · 1 個 reaction ·
-
status:waiting-for-triage type:bug
難度 3/5 1-2 天 新手友好度 52/100
microsoftgraph/msgraph-sdk-python#1578 ·
-
status:waiting-for-triage
難度 5/5 一週以上 新手友好度 25/100
microsoftgraph/msgraph-sdk-python#1557 ·
查看 microsoftgraph/msgraph-sdk-python 的全部 Issue
相似的 Issue
-
good first issue hacktoberfest
難度 1/5 1 小時以內 新手友好度 92/100
維護者通常 1 天內回覆
-
tool-calling
難度 2/5 1-3 小時 新手友好度 88/100
vllm-project/vllm#59838 ·
維護者通常 1 天內回覆
-
難度 1/5 1 小時以內 新手友好度 92/100
raullenchai/Rapid-MLX#4042 ·
維護者通常 1 天內回覆
-
documentation
難度 1/5 1 小時以內 新手友好度 92/100
transitmatters/mbta-slow-zone-bot#70 ·
維護者通常 1 天內回覆
-
bug
難度 2/5 1-3 小時 新手友好度 66/100
open-webui/open-webui#31871 · 1 則留言 ·
維護者通常 1 天內回覆