You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "gschuurman (via GitHub)" <gi...@apache.org> on 2025/12/17 13:24:00 UTC

[PR] Add HTTP PATCH as resource method [airflow]

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

   Add the HTTP patch method as a resouce method to be used in flask app builder.
   Currently patch requires the same permissions as PUT, but is distinctly different from PUT in the intended operation.
   Defining this separatly allows to change permissions at a later point.
   
   closes: #59510
   
   <!--
    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: #59510
   
   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-docs/05_pull_requests.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 [airflow-core/newsfragments](https://github.com/apache/airflow/tree/main/airflow-core/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


Re: [PR] Add HTTP PATCH as resource method [airflow]

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


##########
airflow-core/src/airflow/api_fastapi/auth/managers/base_auth_manager.py:
##########
@@ -75,7 +75,7 @@
 # List of methods (or actions) a user can do against a resource
 ResourceMethod = Literal["GET", "POST", "PUT", "DELETE"]
 # Extends ``ResourceMethod`` to include "MENU". The method "MENU" is only supported with specific resources (menu items)
-ExtendedResourceMethod = Literal["GET", "POST", "PUT", "DELETE", "MENU"]
+ExtendedResourceMethod = Literal["GET", "POST", "PUT", "DELETE", "MENU", "PATCH"]

Review Comment:
   What would it take to have that "PATCH" available for all auth manager?
   
   So we can have code in the API 'matching perms'. "PATCH" permission for PATCH endpoint, instead of "PUT" permission for "PATCH" currently :( 
   
   That would be a good quality of life (even if the "PATCH under the hood maps to a "PATCH")



##########
airflow-core/src/airflow/api_fastapi/auth/managers/base_auth_manager.py:
##########
@@ -75,7 +75,7 @@
 # List of methods (or actions) a user can do against a resource
 ResourceMethod = Literal["GET", "POST", "PUT", "DELETE"]
 # Extends ``ResourceMethod`` to include "MENU". The method "MENU" is only supported with specific resources (menu items)
-ExtendedResourceMethod = Literal["GET", "POST", "PUT", "DELETE", "MENU"]
+ExtendedResourceMethod = Literal["GET", "POST", "PUT", "DELETE", "MENU", "PATCH"]

Review Comment:
   What would it take to have that "PATCH" available for all auth manager?
   
   So we can have code in the API 'matching perms'. "PATCH" permission for PATCH endpoint, instead of "PUT" permission for "PATCH" currently :( 
   
   That would be a good quality of life (even if the "PATCH under the hood maps to a "PUT")



-- 
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] Add HTTP PATCH as resource method [airflow]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] closed pull request #59564: Add HTTP PATCH as resource method
URL: https://github.com/apache/airflow/pull/59564


-- 
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] Add HTTP PATCH as resource method [airflow]

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


##########
airflow-core/src/airflow/api_fastapi/auth/managers/base_auth_manager.py:
##########
@@ -75,7 +75,7 @@
 # List of methods (or actions) a user can do against a resource
 ResourceMethod = Literal["GET", "POST", "PUT", "DELETE"]
 # Extends ``ResourceMethod`` to include "MENU". The method "MENU" is only supported with specific resources (menu items)
-ExtendedResourceMethod = Literal["GET", "POST", "PUT", "DELETE", "MENU"]
+ExtendedResourceMethod = Literal["GET", "POST", "PUT", "DELETE", "MENU", "PATCH"]

Review Comment:
   I completely agree, PUT and PATCH are identical regarding the required permissions. This makes me question If the required in the acctual endpoint should have been PUT instead of PATCH. That would be an easier fix, with less impact to the rest of the airflow codebase and any custom authentication manager.
   
   As for me, I made a temorary overloaded method in my own AuthManager to keep the api endpoint working:
   
   ``` python
     def is_authorized_custom_view(
               self, *, method: ResourceMethod | str, resource_name: str, user: User
       ) -> bool:
           if method == "PATCH":
               method = "PUT"
           return super().is_authorized_custom_view(
               method=method,
               resource_name=resource_name,
               user=user
           )
   ```



-- 
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] Add HTTP PATCH as resource method [airflow]

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

   This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 5 days if no further activity occurs. Thank you for your 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] Add HTTP PATCH as resource method [airflow]

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


##########
airflow-core/src/airflow/api_fastapi/auth/managers/base_auth_manager.py:
##########
@@ -75,7 +75,7 @@
 # List of methods (or actions) a user can do against a resource
 ResourceMethod = Literal["GET", "POST", "PUT", "DELETE"]
 # Extends ``ResourceMethod`` to include "MENU". The method "MENU" is only supported with specific resources (menu items)
-ExtendedResourceMethod = Literal["GET", "POST", "PUT", "DELETE", "MENU"]
+ExtendedResourceMethod = Literal["GET", "POST", "PUT", "DELETE", "MENU", "PATCH"]

Review Comment:
   We should not do that. `ExtendedResourceMethod` list all methods used by the auth managers to define user access to resources. `PATCH` is not used, they use `PUT` instead.
   
   Looking at the issue, what we should do is, update `_MAP_METHOD_NAME_TO_FAB_ACTION_NAME` to accept `str` as opposed to `ExtendedResourceMethod` as key and add `"PATCH": ACTION_CAN_EDIT,` as a new item in the dict. Since the method can be realistically any HTTP method, we should not limit it to  `ExtendedResourceMethod`
   
   



-- 
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] Add HTTP PATCH as resource method [airflow]

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


##########
airflow-core/src/airflow/api_fastapi/auth/managers/base_auth_manager.py:
##########
@@ -75,7 +75,7 @@
 # List of methods (or actions) a user can do against a resource
 ResourceMethod = Literal["GET", "POST", "PUT", "DELETE"]
 # Extends ``ResourceMethod`` to include "MENU". The method "MENU" is only supported with specific resources (menu items)
-ExtendedResourceMethod = Literal["GET", "POST", "PUT", "DELETE", "MENU"]
+ExtendedResourceMethod = Literal["GET", "POST", "PUT", "DELETE", "MENU", "PATCH"]

Review Comment:
   Will that work for all auth managers, so we can finally have in the API code 'matching perms'. "PATCH" permission for PATCH endpoint, instead of "PUT" permission for "PATCH" currently :( 



-- 
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] Add HTTP PATCH as resource method [airflow]

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

   @gschuurman Do you plan to address the CI issues?


-- 
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] Add HTTP PATCH as resource method [airflow]

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


##########
airflow-core/src/airflow/api_fastapi/auth/managers/base_auth_manager.py:
##########
@@ -75,7 +75,7 @@
 # List of methods (or actions) a user can do against a resource
 ResourceMethod = Literal["GET", "POST", "PUT", "DELETE"]
 # Extends ``ResourceMethod`` to include "MENU". The method "MENU" is only supported with specific resources (menu items)
-ExtendedResourceMethod = Literal["GET", "POST", "PUT", "DELETE", "MENU"]
+ExtendedResourceMethod = Literal["GET", "POST", "PUT", "DELETE", "MENU", "PATCH"]

Review Comment:
   +1 for this. That would finally allow us in the API code to have 'matching perms'. "PATCH" permission for PATCH endpoint, instead of "PUT" permission for "PATCH" currently :( 



-- 
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] Add HTTP PATCH as resource method [airflow]

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


##########
airflow-core/src/airflow/api_fastapi/auth/managers/base_auth_manager.py:
##########
@@ -75,7 +75,7 @@
 # List of methods (or actions) a user can do against a resource
 ResourceMethod = Literal["GET", "POST", "PUT", "DELETE"]
 # Extends ``ResourceMethod`` to include "MENU". The method "MENU" is only supported with specific resources (menu items)
-ExtendedResourceMethod = Literal["GET", "POST", "PUT", "DELETE", "MENU"]
+ExtendedResourceMethod = Literal["GET", "POST", "PUT", "DELETE", "MENU", "PATCH"]

Review Comment:
   I do not think we want 1:1 mapping between APIs and HTTP verbs. For example, the difference between `PUT` and `PATCH` is that `PUT` replaces an entire resource, while `PATCH` applies partial modifications to a resource. We do not make such difference in our APIs and auth model, and we should not. The list of methods in our auth model must be a subset of HTTP verbs, HTTP verbs are too granular.
   
   Maybe taking HTTP terminology to specify a method/action in our auth model was not a good idea because it can create confusion but I definitely do not think we should support all HTTP verbs in our auth model.



-- 
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] Add HTTP PATCH as resource method [airflow]

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


##########
airflow-core/src/airflow/api_fastapi/auth/managers/base_auth_manager.py:
##########
@@ -75,7 +75,7 @@
 # List of methods (or actions) a user can do against a resource
 ResourceMethod = Literal["GET", "POST", "PUT", "DELETE"]
 # Extends ``ResourceMethod`` to include "MENU". The method "MENU" is only supported with specific resources (menu items)
-ExtendedResourceMethod = Literal["GET", "POST", "PUT", "DELETE", "MENU"]
+ExtendedResourceMethod = Literal["GET", "POST", "PUT", "DELETE", "MENU", "PATCH"]

Review Comment:
   >I do not think we want 1:1 mapping between APIs and HTTP verbs. For example, the difference between PUT and PATCH is that PUT replaces an entire resource, while PATCH applies partial modifications to a resource. We do not make such difference in our APIs and auth model, and we should not. The list of methods in our auth model must be a subset of HTTP verbs, HTTP verbs are too granular.
   
   > Maybe taking HTTP terminology to specify a method/action in our auth model was not a good idea because it can create confusion but I definitely do not think we should support all HTTP verbs in our auth model.
   
   Makes sense to me to see it that way.



-- 
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] Add HTTP PATCH as resource method [airflow]

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

   > @gschuurman Do you plan to address the CI issues?
   
   I am planning on fixing the CI issues. But I'm currently not close to my laptop. I hope to fix them next week, of the week after. 


-- 
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] Add HTTP PATCH as resource method [airflow]

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


##########
airflow-core/src/airflow/api_fastapi/auth/managers/base_auth_manager.py:
##########
@@ -75,7 +75,7 @@
 # List of methods (or actions) a user can do against a resource
 ResourceMethod = Literal["GET", "POST", "PUT", "DELETE"]
 # Extends ``ResourceMethod`` to include "MENU". The method "MENU" is only supported with specific resources (menu items)
-ExtendedResourceMethod = Literal["GET", "POST", "PUT", "DELETE", "MENU"]
+ExtendedResourceMethod = Literal["GET", "POST", "PUT", "DELETE", "MENU", "PATCH"]

Review Comment:
   I do not think we want 1:1 mapping between APIs and HTTP verbs. For example, the difference between `PUT` and `PATCH` is that `PUT` replaces an entire resource, while `PATCH` applies partial modifications to a resource. We do not make such different in our APIs, and we should not. The list of methods in our auth model must be a subset of HTTP verbs, HTTP verbs are too granular.
   
   Maybe taking HTTP terminology to specify a method/action in our auth model was not a good idea because it can create confusion but I definitely do not think we should support all HTTP verbs in our auth model.



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