You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "lohitkolluri (via GitHub)" <gi...@apache.org> on 2026/06/02 13:09:26 UTC

[PR] fix(imap): Add create_unique_filenames option to prevent attachment overwrites [airflow]

lohitkolluri opened a new pull request, #67899:
URL: https://github.com/apache/airflow/pull/67899

   When downloading mail attachments with the same filename, files were silently overwritten. Added a new ``create_unique_filenames`` parameter (default False) that appends a counter suffix (``_1``, ``_2``, etc.) to the base filename when a file already exists at the target path.
   
   The default is False to preserve backward compatibility - existing behavior of silently overwriting files remains unchanged.
   
   ## Root Cause
   When multiple emails had attachments with the same name, each call to `download_mail_attachments` would silently overwrite the previous file at the same path.
   
   ## Fix
   - Added `_get_unique_filepath` helper that finds the next available filename by incrementing a counter until no collision exists
   - Wired the `create_unique_filenames` flag through `_create_files` and `_create_file`
   - All 38 IMAP hook tests + 2 sensor tests pass
   
   ## Risks
   - Backward compatible: new parameter defaults to `False`
   - No change to existing behavior unless opt-in
   
   closes: #65870
   
   ---
   
   ##### Was generative AI tooling used to co-author this PR?
   
   - [X] Yes — Claude Code (DeepSeek V4 Flash)
   
   Generated-by: Claude Code (DeepSeek V4 Flash) following [the guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] fix(imap): Add create_unique_filenames option to prevent attachment overwrites [airflow]

Posted by "lohitkolluri (via GitHub)" <gi...@apache.org>.
lohitkolluri commented on PR #67899:
URL: https://github.com/apache/airflow/pull/67899#issuecomment-4605848587

   The CI failures in this run are unrelated to the PR changes — both failures are from Docker Hub being unreachable during the initial cleanup step (`docker: Error response from daemon: Get "https://registry-1.docker.io/v2/": net/http: request canceled while waiting for connection`). This is a transient infrastructure issue on the GitHub Actions runners, not a code issue. The branch has been updated with latest `main` to re-trigger CI.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] fix(imap): Prevent IMAP hook from silently overwriting attachments with identical filenames [airflow]

Posted by "lohitkolluri (via GitHub)" <gi...@apache.org>.
lohitkolluri commented on PR #67899:
URL: https://github.com/apache/airflow/pull/67899#issuecomment-4754563674

   Hey just following up to check the status of this PR. Thank you!!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Prevent IMAP hook from silently overwriting attachments with identical filenames [airflow]

Posted by "vincbeck (via GitHub)" <gi...@apache.org>.
vincbeck commented on PR #67899:
URL: https://github.com/apache/airflow/pull/67899#issuecomment-4894930359

   Fixed in https://github.com/apache/airflow/pull/68838


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] fix(imap): Prevent IMAP hook from silently overwriting attachments with identical filenames [airflow]

Posted by "lohitkolluri (via GitHub)" <gi...@apache.org>.
lohitkolluri commented on PR #67899:
URL: https://github.com/apache/airflow/pull/67899#issuecomment-4663855476

   Thanks for the review, @potiuk. I've addressed the items:
   
   - **Provider tests**: The existing test structure already follows the provider distributions guidelines (`tests/unit/PROVIDER/hooks/test_imap.py`) with proper `__init__.py` files and `conftest.py` loading the shared test plugins. The branch has been updated with latest main to re-trigger CI.
   
   - **Test fix**: Also fixed four test methods that were still using the old `create_unique_filenames` parameter name (renamed to `overwrite` during implementation). The tests now call `overwrite=False` as intended and use the correct `"xb"` exclusive-create mode assertions.
   
   The PR body has been updated to reflect the current state. Let me know if anything else needs attention.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Prevent IMAP hook from silently overwriting attachments with identical filenames [airflow]

Posted by "vincbeck (via GitHub)" <gi...@apache.org>.
vincbeck closed pull request #67899: Prevent IMAP hook from silently overwriting attachments with identical filenames
URL: https://github.com/apache/airflow/pull/67899


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] fix(imap): Add create_unique_filenames option to prevent attachment overwrites [airflow]

Posted by "boring-cyborg[bot] (via GitHub)" <gi...@apache.org>.
boring-cyborg[bot] commented on PR #67899:
URL: https://github.com/apache/airflow/pull/67899#issuecomment-4602696564

   Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our [Contributors' Guide](https://github.com/apache/airflow/blob/main/contributing-docs/README.rst)
   Here are some useful points:
   - Pay attention to the quality of your code (ruff, mypy and type annotations). Our [prek-hooks]( https://github.com/apache/airflow/blob/main/contributing-docs/08_static_code_checks.rst#prerequisites-for-prek-hooks) will help you with that.
   - In case of a new feature add useful documentation (in docstrings or in `docs/` directory). Adding a new operator? Check this short [guide](https://github.com/apache/airflow/blob/main/airflow-core/docs/howto/custom-operator.rst) Consider adding an example Dag that shows how users should use it.
   - Consider using [Breeze environment](https://github.com/apache/airflow/blob/main/dev/breeze/doc/README.rst) for testing locally, it's a heavy docker but it ships with a working Airflow and a lot of integrations.
   - Be patient and persistent. It might take some time to get a review or get the final approval from Committers.
   - Please follow [ASF Code of Conduct](https://www.apache.org/foundation/policies/conduct) for all communication including (but not limited to) comments on Pull Requests, Mailing list and Slack.
   - Be sure to read the [Airflow Coding style]( https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#coding-style-and-best-practices).
   - Always keep your Pull Requests rebased, otherwise your build might fail due to changes not related to your commits.
   Apache Airflow is a community-driven project and together we are making it better 🚀.
   In case of doubts contact the developers at:
   Mailing List: dev@airflow.apache.org
   Slack: https://s.apache.org/airflow-slack
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] fix(imap): Prevent IMAP hook from silently overwriting attachments with identical filenames [airflow]

Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on PR #67899:
URL: https://github.com/apache/airflow/pull/67899#issuecomment-4657831346

   @lohitkolluri A few things need addressing before review — see our [Pull Request quality criteria](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#pull-request-quality-criteria).
   
   - :x: **Provider tests**. See [docs](https://github.com/apache/airflow/blob/main/contributing-docs/12_provider_distributions.rst).
   
   No rush.
   
   _Note: This comment was drafted by an AI-assisted triage tool and may contain mistakes. Once you have addressed the points above, an Apache Airflow maintainer — a real person — will take the next look at your PR. We use this [two-stage triage process](https://github.com/apache/airflow/blob/main/contributing-docs/25_maintainer_pr_triage.md#why-the-first-pass-is-automated) so that our maintainers' limited time is spent where it matters most: the conversation with you._


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org