@@ -280,6 +280,7 @@ def test_receiving_get(self) -> None:
280280 "content_type" : "application/pdf" ,
281281 "content_id" : "cid_123" ,
282282 "content_disposition" : "attachment" ,
283+ "size" : 4096 ,
283284 }
284285 ],
285286 }
@@ -332,6 +333,61 @@ def test_receiving_get_with_no_attachments(self) -> None:
332333 assert email ["reply_to" ] is None
333334 assert len (email ["attachments" ]) == 0
334335
336+ def test_receiving_get_with_nullable_attachment_fields (self ) -> None :
337+ # Inbound MIME parts (S/MIME signatures, calendar invites) can return
338+ # null for filename, content_id, and content_disposition.
339+ # See: https://linear.app/resend/issue/DEV-934
340+ self .set_mock_json (
341+ {
342+ "object" : "inbound" ,
343+ "id" : "67d9bcdb-5a02-42d7-8da9-0d6feea18cff" ,
344+ "to" : ["received@example.com" ],
345+ "from" : "sender@example.com" ,
346+ "created_at" : "2023-04-07T23:13:52.669661+00:00" ,
347+ "subject" : "Signed inbound email" ,
348+ "html" : None ,
349+ "text" : "hello world" ,
350+ "bcc" : None ,
351+ "cc" : None ,
352+ "reply_to" : None ,
353+ "headers" : {},
354+ "message_id" : "<msg@example.com>" ,
355+ "attachments" : [
356+ {
357+ "id" : "f5e32216-3017-4118-97d5-5c84d991bf98" ,
358+ "filename" : "smime.p7s" ,
359+ "content_type" : "application/pkcs7-signature" ,
360+ "content_id" : None ,
361+ "content_disposition" : "attachment" ,
362+ "size" : 1361 ,
363+ },
364+ {
365+ "id" : "68136802-3577-4911-a7d2-b303e61261ac" ,
366+ "filename" : None ,
367+ "content_type" : "text/calendar" ,
368+ "content_id" : None ,
369+ "content_disposition" : None ,
370+ "size" : 1152 ,
371+ },
372+ ],
373+ }
374+ )
375+
376+ email : resend .ReceivedEmail = resend .Emails .Receiving .get (
377+ email_id = "67d9bcdb-5a02-42d7-8da9-0d6feea18cff" ,
378+ )
379+ assert len (email ["attachments" ]) == 2
380+
381+ smime = email ["attachments" ][0 ]
382+ assert smime ["filename" ] == "smime.p7s"
383+ assert smime ["content_disposition" ] == "attachment"
384+ assert smime ["content_id" ] is None
385+
386+ calendar = email ["attachments" ][1 ]
387+ assert calendar ["filename" ] is None
388+ assert calendar ["content_disposition" ] is None
389+ assert calendar ["content_id" ] is None
390+
335391 def test_should_receiving_get_raise_exception_when_no_content (self ) -> None :
336392 self .set_mock_json (None )
337393 with self .assertRaises (NoContentError ):
0 commit comments