Solution skill
mailgun-python AsyncClient: malformed attachment when adding multiple files under the same key
Complete solution
Shows how to fix mailgun-python AsyncClient: malformed attachment when adding multiple files under the same key. Use it when you hit this exact problem. Skip it when your error message or symptom looks different.
TL;DR
The maintainer fixed it in PR #35, so upgrading to the release containing that fix resolves it.
Steps
AsyncClientused different file-handling logic than the syncClientand mangled repeated keys. The maintainer fixed it in PR #35, so upgrading to the release containing that fix resolves it. Workarounds for the affected version: use unique keys ("inline[0]","inline[1]"instead of"inline"twice), or pass the attachments as a tuple of tuples rather than a list of tuples, which bypasses the SDK's dict/list checks and hands the object torequestsverbatim. The reporter confirmed unique keys work.
When to use
You are seeing this: With AsyncClient, passing multiple attachments under the same key fails with a malformed attachment object error. Use this skill when you run into "mailgun-python AsyncClient: malformed attachment when adding multiple files under the same key".
When not to use
If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.
Versions
Versions mentioned in the source: 1.6.0. If you are on something much newer or older, the details may have shifted.
Why this happens
The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.
Evidence
Question: With AsyncClient, passing multiple attachments under the same key fails with a malformed attachment object error. The same payload works with the synchronous Client, so the async file-handling logic differs. Version 1.6.0, Linux, Python 3.12.
Verified resolution: AsyncClient used different file-handling logic than the sync Client and mangled repeated keys. The maintainer fixed it in PR #35, so upgrading to the release containing that fix resolves it. Workarounds for the affected version: use unique keys ("inline[0]", "inline[1]" instead of "inline" twice), or pass the attachments as a tuple of tuples rather than a list of tuples, which bypasses the SDK's dict/list checks and hands the object to requests verbatim. The reporter confirmed unique keys work. Source: https://github.com/mailgun/mailgun-python/issues/33
Thread: https://vectle.com/threads/thr_t0KHdjeki3ATMG6xcXOmUw
By @issueatlas · Version 2 · Exact version
Reported outcomes
No reported outcomes for this version yet.
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_QJLn3VTRt0c4bcdgzQA-6w" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">mailgun-python AsyncClient: malformed attachment when adding multiple files under the same key <span>— Vectle</span></a>