Add max_mails parameter to attachment methods in IMAP hook#60963
Add max_mails parameter to attachment methods in IMAP hook#60963shahar1 merged 13 commits intoapache:mainfrom
Conversation
|
@Bucky789 |
shahar1
left a comment
There was a problem hiding this comment.
Please add unit tests and ensure you refer to the edge cases
|
Hello, Please let me know if anything else should be adjusted. |
|
Thanks for the review and approval! Let me know if any final adjustments are needed. This was my first ever open source contribution!! |
shahar1
left a comment
There was a problem hiding this comment.
Good job! Looks like you're on the way, but there are some fixes to do.
Please let me know once you're done.
|
@shahar1 Thanks for pointing this out. |
|
I’ve updated the implementation to align with the suggested approach: the logic now limits the number of mail IDs before reversing, so we avoid unnecessary work while still preserving the “latest first” behavior. This removes the extra overhead and keeps the intent of max_mails clear. The changes have been pushed, and all provider IMAP tests are passing locally. |
|
Hi! @shahar1 Just checking in on this PR, are there any additional changes or feedback needed from my side? Thanks! |
Hey, I'll rerun the CI and if everything is green - I'll approve & merge before the cutting the release today. |
|
Awesome work, congrats on your first merged pull request! You are invited to check our Issue Tracker for additional contributions. |
|
Well done @Bucky789 ! |
|
@shahar1 Everything works as expected, exept one detail. Since some files have same names, download_mail_attachments method overwrites them. So instead of 6 files I get 4. But I guess this is topic for another issue). Please let me know if this is sufficient testing. Also, should I write the results in your testing providers issue? |
Please also comment in the providers status issue. If it overwrites files, I tend to potspone the release of this provider to RC2 and hopefully we could solve it by then (if you could help with it, it would be great). |
Adds an optional
max_mailsparameter to IMAP hook attachment methods to allow limiting the number of latest emails processed while still retrieving all attachments from those emails.This preserves existing behavior when
max_mails=None.Motivation
Currently, users must either:
latest_only=Trueand receive only a single attachmentThere is no way to retrieve all attachments from the last N matching emails.
Changes
max_mailsparameter to:retrieve_mail_attachmentsdownload_mail_attachments_list_mail_ids_descFixes: #60836
Was generative AI tooling used to co-author this PR?
Generated-by: ChatGPT 5.2 following the guidelines
{pr_number}.significant.rstor{issue_number}.significant.rst, in airflow-core/newsfragments.