You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2022/09/04 07:38:13 UTC

[GitHub] [airflow] subhosuper opened a new issue, #26149: If render_template_as_native_obj=True SimpleHttpOperator converts header values to integer automatically

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

   ### Apache Airflow version
   
   Other Airflow 2 version
   
   ### What happened
   
   If render_template_as_native_obj=True 
   SimpleHttpOperator converts header values to integer automatically.
    
   `headers = {"Content-Type": "application/json", "accept": "application/json", "Accept-Version": "V2", "OTP": "123345"}` is interpretted as `headers = {"Content-Type": "application/json", "accept": "application/json", "Accept-Version": "V2", "OTP": 123345}`
   
   OTP value has to be of string datatype but characters are numbers.
   
   Airflow automatically converts this OTP value to integer whereas the endpoint wants OTP value as string.
   This is the error from the endpoint, this is to explain the error I am getting from airflow 
   `requests.exceptions.InvalidHeader: Value for header {OTP: 123345} must be of type str or bytes, not <class 'int'>`
   
   If render_template_as_native_obj=False, then SimpleHttpOperator works just fine but I want to use render_template_as_native_obj=True  for other requirements.
   
   ### What you think should happen instead
   
   Expected: 
   Please suggest a way to use render_template_as_native_obj=True and be able to send numbers as string in headers of SimpleHttpOperators
   
   ### How to reproduce
   
   ```
   with DAG('xcom_dag', schedule_interval='@daily', default_args=default_args, catchup=False, render_template_as_native_obj=True) as dag:
         task = SimpleHttpOperator(
                 task_id = 'taskname',
                 method = "POST",
                 http_conn_id = "host",
                 endpoint = "/enspoint",
                 headers = '{{"Content-Type": "application/json", "accept": "application/json", "Accept-Version": "V2", "OTP": "123345")}}',
                 data = json.dumps({"csr": "{{ ti.xcom_pull(task_ids='task1', key='return_value').replace(' ', '')}}" }),
                 response_check = lambda response: _handle_response_check(response),
                 response_filter = lambda response: {"id": response.json()["id"], "token": response.json()["token"], "secret": response.json()["secret"]}
             )
   ```
         
   This is how the task looks like.
   
   
   ### Operating System
   
   Ubuntu 20.04
   
   ### Versions of Apache Airflow Providers
   
   apache/airflow:2.3.0 as base image
   Using this image with helm
   
   ### Deployment
   
   Official Apache Airflow Helm Chart
   
   ### Deployment details
   
   Deploying with helm in Kubernetes cluster k8s
   
   ### 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: commits-unsubscribe@airflow.apache.org.apache.org

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


[GitHub] [airflow] boring-cyborg[bot] commented on issue #26149: If render_template_as_native_obj=True SimpleHttpOperator converts header values to integer automatically

Posted by GitBox <gi...@apache.org>.
boring-cyborg[bot] commented on issue #26149:
URL: https://github.com/apache/airflow/issues/26149#issuecomment-1236279968

   Thanks for opening your first issue here! Be sure to follow the issue template!
   


-- 
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] potiuk commented on issue #26149: If render_template_as_native_obj=True SimpleHttpOperator converts header values to integer automatically

Posted by GitBox <gi...@apache.org>.
potiuk commented on issue #26149:
URL: https://github.com/apache/airflow/issues/26149#issuecomment-1242943264

   I do not think this is an issue - this is how native rendering works. There is not much we can do about it. 
   
   But I suggest you to try some workarounds. Likely proper escaping of the first digit with unicode character - "\0x3123345" should work - @subhosuper  can you please experiment with it and see if it works ? If so, then maybe you can contribute a Doc on how to treat similar issues as a contribution to our documentaiton.
   
   Looking forward to results of your experiment. And converting it into discussion.


-- 
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] subhosuper commented on issue #26149: If render_template_as_native_obj=True SimpleHttpOperator converts header values to integer automatically

Posted by GitBox <gi...@apache.org>.
subhosuper commented on issue #26149:
URL: https://github.com/apache/airflow/issues/26149#issuecomment-1237282565

   @potiuk 


-- 
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] subhosuper commented on issue #26149: If render_template_as_native_obj=True SimpleHttpOperator converts header values to integer automatically

Posted by GitBox <gi...@apache.org>.
subhosuper commented on issue #26149:
URL: https://github.com/apache/airflow/issues/26149#issuecomment-1236534539

   @kaxil @wolfier 


-- 
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] potiuk closed issue #26149: If render_template_as_native_obj=True SimpleHttpOperator converts header values to integer automatically

Posted by GitBox <gi...@apache.org>.
potiuk closed issue #26149: If render_template_as_native_obj=True SimpleHttpOperator converts header values to integer automatically
URL: https://github.com/apache/airflow/issues/26149


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