You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "pankajkoti (via GitHub)" <gi...@apache.org> on 2023/08/03 06:08:18 UTC

[GitHub] [airflow] pankajkoti opened a new pull request, #33062: Add a utility to safely join URLs using urllib.parse.urljoin

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

   While working with `log_url` property of the task instances, 
   it is observed that `urljoin` ignores the part of the path after 
   the last slash specified in the base_url when it does not end 
   with a trailing slash and Airflow webserver does not allow 
   setting the base_url with a trailing slash. Additionally, it is also 
   observed that if the relative URL has a leading slash, `urljoin` 
   just ingores the base URL and returns the relative URL. 
   Hence, we add a new utlity method `safe_urljoin` to handle 
   these cases.
   
   closes: #32996
   
   <!--
    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/
   -->
   
   
   
   <!-- Please keep an empty line above the dashes. -->
   ---
   **^ Add meaningful description above**
   
   Read the **[Pull Request Guidelines](https://github.com/apache/airflow/blob/main/CONTRIBUTING.rst#pull-request-guidelines)** for more information.
   In case of fundamental code changes, an Airflow Improvement Proposal ([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvement+Proposals)) is needed.
   In case of a new dependency, check compliance with the [ASF 3rd Party License Policy](https://www.apache.org/legal/resolved.html#category-x).
   In case of backwards incompatible changes please leave a note in a newsfragment file, named `{pr_number}.significant.rst` or `{issue_number}.significant.rst`, in [newsfragments](https://github.com/apache/airflow/tree/main/newsfragments).
   


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


[GitHub] [airflow] uranusjr commented on pull request #33062: Add a utility to safely join URLs using urllib.parse.urljoin

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

   Instead of needing to jump through all these, I would just fix all the second arguments to use absolute paths (e.g. `/graph`) and just use prepend the prefix as a string, without going through `urljoin` at all.


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


[GitHub] [airflow] pankajkoti closed pull request #33062: Add a utility to safely join URLs using urllib.parse.urljoin

Posted by "pankajkoti (via GitHub)" <gi...@apache.org>.
pankajkoti closed pull request #33062: Add a utility to safely join URLs using urllib.parse.urljoin
URL: https://github.com/apache/airflow/pull/33062


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


[GitHub] [airflow] uranusjr commented on pull request #33062: Add a utility to safely join URLs using urllib.parse.urljoin

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

   See my comment in https://github.com/apache/airflow/pull/31833#discussion_r1282696916
   
   The prefix should not have a trailing slash. The path that gets appended to it should have a leading slash, and `urljoin` is the wrong function to join the two. The fix should be to not use `urljoin`, not to wrangle in additional logic to call `urljoin`.


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


[GitHub] [airflow] pankajkoti commented on pull request #33062: Add a utility to safely join URLs using urllib.parse.urljoin

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

   > Instead of needing to jump through all these, I would just fix all the second arguments to use absolute paths (e.g. `/graph`) and just use prepend the prefix as a string, without going through `urljoin` at all.
   
   I think the problem comes when the base URL is set to contain no trailing slash in the config. 
   e.g. like mentioned in the [issue](https://github.com/apache/airflow/issues/32996) when the base path is set to `https://my.astronomer.run/path`, urljoin takes the base path as just `https://my.astronomer.run/`


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


[GitHub] [airflow] pankajkoti commented on pull request #33062: Add a utility to safely join URLs using urllib.parse.urljoin

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

   okay, understood. Thanks a lot @uranusjr . 
   
   Closing this PR and will create a new PR with the suggested changes.


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