Fix treatment of "#" in S3Hook.parse_s3_url()#41796
Merged
Merged
Conversation
|
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)
|
vincbeck
approved these changes
Aug 28, 2024
ferruzzi
approved these changes
Aug 28, 2024
Contributor
|
Static checks are failing, running the pre-commit should auto resolve them |
8fa89da to
ca4aa16
Compare
Contributor
|
static tests are failing |
The current implementation of parse_s3_url will truncate a key if it contains an octothorpe character. By passing the allow_fragments=False argument to urlsplit, keys will be correctly parsed.
eladkal
approved these changes
Aug 29, 2024
|
Awesome work, congrats on your first merged pull request! You are invited to check our Issue Tracker for additional contributions. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Apache Airflow version
2.8.4 in my environment, but the issue is still present in main
What happened
A client submitted an S3 file to my workflow with an octothorpe in the filename, essentially
s3://my-bucket/path/to/key/email campaign - PO# 123456_REPORT.csv. When my Airflow DAG tried to parse this URL, part of the filename was lost:What you think should happen instead
The key should not be truncated. The result of the above example should be
('my-bucket', 'path/to/key/email campaign - PO# 123456_REPORT.csv')How to reproduce:
Call
S3Hook.parse_s3_url()with a#character in the S3 URL. Everything after the#is lost, because urllib.parse.urlsplit() is current called with the default optionallow_fragments=True.This PR passes
allow_fragments=Falsetourlsplitto prevent this error. As far as I can tell, there are no valid cases of#in an S3 key being treated as a fragment, and no existing GitHub issue to fix this.Operating System
Ubuntu 22.04
Versions of Apache Airflow Providers
Deployment
This may be reproduced without deploying
Are you willing to submit PR?
Code of Conduct