karunpoudel opened a new issue #22702: URL: https://github.com/apache/airflow/issues/22702
### Apache Airflow version 2.2.2 ### What happened Gantt chart doesn't show up if you provide vault annotation in executor_config in your task. Vault annotation generally needs a template string where you need to use double quotes and newline like shown below.  Following is console log from google chrome browser when opening Gantt chart page  which refers to this line of code  Browser is not able to parse the json string because it not generated correctly to handle backslash that might show up in taskinstance log (as shown above). This throws error: ``` JSON.parse('{"vault.hashicorp.com/agent-inject-template-artifactory":"\n {{- with secret \"secret/data/nastdomains/artifactory\" -}}\n {{- .Data.data | toJSON -}}\n {{- end }}"}') Unexpected token in JSON at position 58 ``` ### What you think should happen instead The taskinstance result should be properly escaped for backslash character when writing to html document. Instead of exporting `{"vault.hashicorp.com/agent-inject-template-artifactory": "\n {{- with secret \"path/to/secrets\" -}}\n {{- .Data.data | toJSON -}}\n {{- end }}"}` it should be exported as `{"vault.hashicorp.com/agent-inject-template-artifactory": "\\n {{- with secret \\"path/to/secrets\\" -}}\\n {{- .Data.data | toJSON -}}\\n {{- end }}"}` So that is can be correctly consumed by JSON.parse() javascript function. ### How to reproduce Create a DAG with following code. Trigger the DAG. After it completes (either success or failure), go to Gantt view. ``` from airflow import DAG from airflow.operators.dummy import DummyOperator from kubernetes.client import models as k8s import pendulum annotations = { 'vault.hashicorp.com/agent-inject': 'true', 'vault.hashicorp.com/role': f'vault-role', 'vault.hashicorp.com/agent-pre-populate-only': 'true', f'vault.hashicorp.com/agent-inject-secret-filename': 'path/to/secret', f'vault.hashicorp.com/agent-inject-template-filename': f""" {{{{- with secret "path/to/secret" -}}}} {{{{- .Data | toJSON -}}}} {{{{- end }}}}""" } dag = DAG( dag_id="example2", start_date=pendulum.datetime(2021, 1, 1), schedule_interval=None, max_active_runs=1, catchup=False, ) with dag: t0 = DummyOperator( task_id='start', executor_config={ "pod_override": k8s.V1Pod( metadata=k8s.V1ObjectMeta(annotations=annotations), ) } ) ``` ### Operating System Debian GNU/Linux 11 (bullseye) ### Versions of Apache Airflow Providers apache-airflow-providers-cncf-kubernetes==1!2.1.0 ### Deployment Astronomer ### 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]
