PadmajaPeri opened a new issue, #26375:
URL: https://github.com/apache/airflow/issues/26375

   ### Apache Airflow version
   
   Other Airflow 2 version
   
   ### What happened
   
   We are using Airflow 2.3.1 Version. Apart from Airflow provided REST 
endpoints, we are also using the airflow webserver to host our own application 
REST API endpoints. We are doing this by loading our own blueprints and 
registering Flask Blueprint routes within the airflow plugin. 
   
   Issue: Our Custom REST API endpoints are returning incorrect HTTP Error 
response code of 404 when 405 is expected (Invoke the REST API endpoint with an 
incorrect HTTP method, say POST instead of PUT) . This was working in airflow 
1.x but is giving an issue with airflow 2.x
   
   Here is a sample airflow plugin code . If the '/sample-app/v1' API below is 
invoked with POST method, I would expect a 405 response. However, it returns a 
404. 
   
   I tried registering a blueprint error handler for 405 inside the plugin, but 
that did not work.
   
   ```
   test_bp = flask.Blueprint('test_plugin', __name__)
   
   @test_bp.route(
       '/sample-app/v1/tags/<tag>', methods=['PUT'])
   def initialize_deployment(tag):
       """
       Initialize the deployment of the metadata tag
   
       :rtype: flask.Response
       """
       return 'Hello, World'
   
   class TestPlugin(plugins_manager.AirflowPlugin):
       name = 'test_plugin'
       flask_blueprints = [test_bp]
   ```
   
   
   ### What you think should happen instead
   
   Correct HTTP Error response code should be returned.
   
   ### How to reproduce
   
   Issue the following curl request after loading the plugin - 
   
   curl -X POST "http://localhost:8080/sample-app/v1/tags/abcd"; -d '' 
   
   The response will be 404 instead of 405.
   
   ### Operating System
   
   Ubuntu
   
   ### Versions of Apache Airflow Providers
   
   _No response_
   
   ### Deployment
   
   Docker-Compose
   
   ### Deployment details
   
   _No response_
   
   ### Anything else
   
   _No response_
   
   ### Are you willing to submit PR?
   
   - [ ] 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