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

   ### Apache Airflow version
   
   2.5.1
   
   ### What happened
   
   When i made these patch requests to update description of the variable via 
axios
   
   ### 1) Trying to modify new value and description
   ```javascript
   
   let payload ={ key : "example_variable", value : "new_value", description: 
"new_Description" }
   axios.patch("https://localhost:8080/api/v1/variables/example_variable"; , 
payload ,
   {
       auth : {
           username : "username",
           password : "password"
       },
       headers: {
           "Content-Type" : "application/json",
        }
   });
   ```
   
   following response received and In the airflow , Existing Variable's 
```Description``` is cleared and set to ```None```
   
   ```html 
   response body : {
       "description" : "new_Description",
       "key": "example_variable",
       "value" : "new_value"
   }
   ```
   
   ### 2) Trying to update Description with update_mask
   ```javascript
   
   let payload ={ key : "example_variable", value : "value", description: 
"new_Description" }
   
axios.patch("https://localhost:8080/api/v1/variables/example_variable?update_mask=description";
 , payload ,
   {
       auth : {
           username : "username",
           password : "password"
       },
       headers: {
           "Content-Type" : "application/json",
        }
   });
   ```
   
   following response received
   
   ```html 
   response body : {
       "detail" : null,
       "status": 400,
       "detail" : "No field to update",
       "type" : 
"https://airflow.apache.org/docs/apache-airflow/2.5.0/stable-rest-api-ref.html#section/Errors/BadRequest";
   }
   ```
   
   ### What you think should happen instead
   
   The filed "description" is ignored both while setting the Variable (L113) 
and ```update_mask``` (L107-111).
   
   
   
https://github.com/apache/airflow/blob/1768872a0085ba423d0a34fe6cc4e1e109f3adeb/airflow/api_connexion/endpoints/variable_endpoint.py#L97-L115
   
   Also in Variable setter its set to ```None``` if input doesn't contain 
description field
   
https://github.com/apache/airflow/blob/1768872a0085ba423d0a34fe6cc4e1e109f3adeb/airflow/models/variable.py#L156-L165
   
   ### How to reproduce
   
   ## PATCH in Airflow REST API
   
   ### API call
   
"https://localhost:8080/api/v1/variables/example_variable?update_mask=description";
   
   ### payload
   { key : "example_variable", value : "value", description: "new_Description" }
   
   ### headers
   "Content-Type" : "application/json"
   
   OR
   
   ### API call
   "https://localhost:8080/api/v1/variables/example_variable
   
   ### payload
   { key : "example_variable", value : "new_value", description: 
"new_Description" }
   
   ### headers
   "Content-Type" : "application/json"
   
   ### Operating System
   
   Ubuntu 22.04.1 LTS
   
   ### Versions of Apache Airflow Providers
   
   _No response_
   
   ### Deployment
   
   Official Apache Airflow Helm Chart
   
   ### Deployment details
   
   _No response_
   
   ### Anything else
   
   Possible Solution to update Description field can be like
   
   
https://github.com/apache/airflow/blob/1768872a0085ba423d0a34fe6cc4e1e109f3adeb/airflow/api_connexion/endpoints/connection_endpoint.py#L134-L145
   
   ### 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: commits-unsubscr...@airflow.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to