List and Dict template fields are rendered as JSON.
See original GitHub issueApache Airflow version: 2.0.0
Kubernetes version (if you are using kubernetes) (use kubectl version
): n/a
Environment: Linux
- Cloud provider or hardware configuration: amd64
- OS (e.g. from /etc/os-release): Centos 7
- Kernel (e.g.
uname -a
): - Install tools: pip
- Others:
What happened:
The field sql
is rendered as a serialized json ["select 1 from dual", "select 2 from dual"]
instead of a list of syntax-highlighted SQL statements.
What you expected to happen:
lists
and dicts
should be rendered as lists and dicts rather than serialized json unless the template_field_renderer
is json
How to reproduce it:
from airflow import DAG
from airflow.providers.oracle.operators.oracle import OracleOperator
with DAG("demo", default_args={owner='airflow'}, start_date= pendulum.yesterday(), schedule_interval='@daily',) as dag:
OracleOperator(task_id='single', sql='select 1 from dual')
OracleOperator(task_id='list', sql=['select 1 from dual', 'select 2 from dual'])
Anything else we need to know:
Introduced by #11061, .
A quick and dirty work-around:
Edit file airflow/www/views.py
if renderer in renderers:
- if isinstance(content, (dict, list)):
+ if isinstance(content, (dict, list)) and renderer is renderers['json']:
content = json.dumps(content, sort_keys=True, indent=4)
html_dict[template_field] = renderers[renderer](content)
Issue Analytics
- State:
- Created 3 years ago
- Comments:10 (4 by maintainers)
Top Results From Across the Web
Get list of fields from list of objects (dict) imported from json
I am developing a tool for generating docx reports from a database and a template file. The first part of the tool is...
Read more >Parse JSON to fill in elm-UI Template - Learn - Elm Discourse
Hi. I have a bunch of preexisting JSON files. This JSON contains business information that I need to render. For starters I'd like...
Read more >Dictionary attributes - Product Documentation | ServiceNow
Name Value Target Element
allow_null true/false field_name field
allow_public true/false table_name field
allow_references true/false field_name field
Read more >Working With JSON Data in Python - GeeksforGeeks
Python supports JSON through a built-in package called JSON. ... to load from a string, otherwise, the root object is in a list...
Read more >Request and response objects - Django documentation
A dictionary-like object containing all given HTTP POST parameters, ... For use in, for example, Django templates, headers can also be looked up...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Awesome thanks !! @mik-laj
I don’t remember it too, but it may have been only issue of
sql
.