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

   <!--
    Licensed to the Apache Software Foundation (ASF) under one
    or more contributor license agreements.  See the NOTICE file
    distributed with this work for additional information
    regarding copyright ownership.  The ASF licenses this file
    to you under the Apache License, Version 2.0 (the
    "License"); you may not use this file except in compliance
    with the License.  You may obtain a copy of the License at
   
      http://www.apache.org/licenses/LICENSE-2.0
   
    Unless required by applicable law or agreed to in writing,
    software distributed under the License is distributed on an
    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    KIND, either express or implied.  See the License for the
    specific language governing permissions and limitations
    under the License.
    -->
   
   <!--
   Thank you for contributing! Please make sure that your code changes
   are covered with tests. And in case of new features or big changes
   remember to adjust the documentation.
   
   Feel free to ping committers for the review!
   
   In case of an existing issue, reference it using one of the following:
   
   closes: #ISSUE
   related: #ISSUE
   
   How to write a good git commit message:
   http://chris.beams.io/posts/git-commit/
   -->
   ### 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:
   
   ```python
   >>> s3_key = 's3://my-bucket/path/to/key/email campaign - PO# 
123456_REPORT.csv'
   >>> S3Hook.parse_s3_url(s3_key)
   ('my-bucket', 'path/to/key/email campaign - PO')
   ```
    ### What you think should happen instead
   
   The key should not be truncated. The result of the above example should be 
`('my-bucket', '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 option `allow_fragments=True`.
   
   This PR passes `allow_fragments=False` to `urlsplit` to 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
   
   |Provider|Version|
   |:--|:--|
   |apache-airflow-providers-amazon|8.20.0|
   |apache-airflow-providers-celery|3.6.2|
   |apache-airflow-providers-common-io|1.3.1|
   |apache-airflow-providers-common-sql|1.12.0|
   |apache-airflow-providers-ftp|3.8.0|
   |apache-airflow-providers-http|4.10.1|
   |apache-airflow-providers-imap|3.5.0|
   |apache-airflow-providers-postgres|5.10.2|
   |apache-airflow-providers-sendgrid|3.4.0|
   |apache-airflow-providers-sftp|4.9.1|
   |apache-airflow-providers-smtp|1.6.1|
   |apache-airflow-providers-sqlite|3.7.1|
   |apache-airflow-providers-ssh|3.10.1|
   
   ### Deployment
   
   This may be reproduced without deploying
   
   ### Are you willing to submit PR?
   - [x] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   - [x] I agree to follow this project's [Code of 
Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to