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

[PR] Keep S3 directory sync within the requested prefix [airflow]

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

   `S3Hook.sync_to_local_dir()` can fail when a directory prefix has no trailing slash and the bucket contains a sibling key with the same string prefix. For example, syncing `dags` also lists `dags_archive/old.py`, which cannot be made relative to the `dags` directory. An object named exactly `dags` can instead be downloaded to the local directory's path, preventing subsequent downloads. This also affects `S3DagBundle` initialization and refresh.
   
   Normalize non-empty directory prefixes to end in `/` before listing objects. Empty prefixes still sync the whole bucket, and the existing local path containment check remains in place.
   
   Validation:
   
   - All six new Moto-backed regression cases fail without the fix: four with `ValueError` and two with `NotADirectoryError`.
   - The S3 hook and S3 Dag bundle test files pass: 170 tests on Python 3.10.21 in the official Linux/amd64 Breeze CI image.
   - Regular and manual prek checks pass, including provider-wide mypy.
   - The complete Amazon unit suite passes when run serially in Breeze: 5,204 passed, 44 skipped.
   
   An earlier non-DB run with two xdist workers had one failure in `TestGlueDataQualityHook.test_validate_evaluation_results_show_results_True`, due to Pandas table wrapping in the captured log. The same isolated test fails with two workers on the unchanged base (`7e5c580cd6858b9f873fdcde65bed26182bcf379`) as well. It passes in the complete serial run above. No Glue code or tests are changed here. The broader dependent-provider and older-Airflow compatibility matrices have not been run locally.
   
   No live AWS calls were made.
   
   ---
   
   ##### Was generative AI tooling used to co-author this PR?
   
   - [X] Yes — OpenAI Codex (GPT-6).
   
   Generated-by: OpenAI Codex (GPT-6) 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] Keep S3 directory sync within the requested prefix [airflow]

Posted by "rjgoyln (via GitHub)" <gi...@apache.org>.
rjgoyln commented on code in PR #73756:
URL: https://github.com/apache/airflow/pull/73756#discussion_r4115160891


##########
providers/amazon/tests/unit/amazon/aws/hooks/test_s3.py:
##########
@@ -2052,6 +2052,20 @@ def get_logs_string(call_args_list):
         assert "local file last modified" in logs_string
         assert "Downloaded dag_04.py to" in logs_string
 
+    @pytest.mark.parametrize("s3_prefix", ["dags", "project/dags"])
+    @pytest.mark.parametrize("sibling_suffix", ["_archive/old.py", "_old.py", ""])

Review Comment:
   The "" case isn't really a sibling key — it's a key equal to the prefix, and it fails differently without the fix (NotADirectoryError rather than the ValueError from relative_to). Giving it an explicit id would make that distinction clearer in CI failures.
   
   ```suggestion
       @pytest.mark.parametrize(
           "sibling_suffix", ["_archive/old.py", "_old.py", pytest.param("", id="key_equals_prefix")]
       )
   ```



-- 
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] Keep S3 Dag bundle downloads within the configured directory [airflow]

Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk merged PR #73756:
URL: https://github.com/apache/airflow/pull/73756


-- 
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] Keep S3 directory sync within the requested prefix [airflow]

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

   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] Keep S3 Dag bundle downloads within the configured directory [airflow]

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

   Following up after moving the prefix normalization into S3DagBundle. The targeted tests and local checks passed. Could a maintainer approve the pending CI runs and take another look when available? Thanks!


-- 
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