FileAttachment.content_bytes does not return b64-encoded content.
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 3/5
- Temps estimé
- 1-2 jours
- Accessibilité débutants
- 55/100
Piste de recherche
Commencez par le champ content_bytes du modèle FileAttachment et l'appel de récupération de la pièce jointe dans la reproduction. Comparez le comportement entre les versions 1.58.0 et 1.60.0 du SDK, puis exécutez la validation b64decode fournie avec une pièce jointe récupérée. C'est terminé lorsque content_bytes peut être transmis à b64decode avec validate=True comme décrit.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
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_
- Langage dominant
- Python
- Étoiles
- 630
- Forks
- 96
- Merge moyen
- 15 h 20 min
- PR mergées (30 j)
- 3
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de microsoftgraph/msgraph-sdk-python
-
status:waiting-for-triage type:bug
Difficulté 1/5 Moins d'une heure Accessibilité débutants 90/100
microsoftgraph/msgraph-sdk-python#1570 ·
-
status:waiting-for-triage type:bug
Difficulté 2/5 1-3 heures Accessibilité débutants 75/100
microsoftgraph/msgraph-sdk-python#1563 ·
-
Needs: Attention :wave: type:bug
Difficulté 2/5 1-3 heures Accessibilité débutants 62/100
microsoftgraph/msgraph-sdk-python#1287 · 2 commentaires · 1 réaction ·
-
Batch Request Support Ouvertestatus:waiting-for-triage
Difficulté 5/5 Plus d'une semaine Accessibilité débutants 25/100
microsoftgraph/msgraph-sdk-python#1557 ·
-
status:waiting-for-triage type:bug
Difficulté 3/5 1-2 jours Accessibilité débutants 52/100
microsoftgraph/msgraph-sdk-python#1542 ·
Toutes les issues de microsoftgraph/msgraph-sdk-python
Issues similaires
-
Difficulté 1/5 Moins d'une heure Accessibilité débutants 90/100
-
bug
Difficulté 2/5 1-3 heures Accessibilité débutants 86/100
zostera/django-bootstrap4#894 ·
-
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
use-agent-os/agent-os#3276 ·
-
Difficulté 2/5 1-3 heures Accessibilité débutants 88/100
zephyrproject-rtos/zephyr#119726 ·
-
area/auth bug comp/agent P3 platform/discord type/security
Difficulté 2/5 1-3 heures Accessibilité débutants 88/100
NousResearch/hermes-agent#117848 ·