XD-DENG opened a new pull request #13024:
URL: https://github.com/apache/airflow/pull/13024


   This PR is to address a _minor_ issue in the nice new feature 
(https://github.com/apache/airflow/pull/12704) supporting YAML/JSON format for 
CLI `list` commands (e.g., list connections, users, etc).
   
   This should NOT affect anything regarding 2.0.0rc1. We can include this in 
something like 2.0.1 or 2.1.
   
   ### Description
   
   If there is any `None` value in the data, it is rendered as string `"None"` 
in the YAML/JSON format. This is incorrect, because `None` value is represented 
as `null` in both YAML and JSON, and only when it's `null` it will be 
recognized as "missing" value. `"None"` in YAML or JSON will be considered as a 
normal string.
   
   With this issue, people may get unexpected behaviour when they try to parse 
the YAML/JSON results.
   
   ### Solution
   
   Don't explicitly convert `None` to string.
   
   ### Sample Code to Reproduce The Issue
   
   ```python
   >>> import yaml
   >>> yaml.safe_load("- name: None")
   [{'name': 'None'}]
   >>> yaml.safe_load("- name: null")
   [{'name': None}]
   ```
   
   ### CLI Output BEFORE This Fix (command `airflow connections list -o 
[json|yaml]`)
   
   <img width="393" alt="Default__-zsh_" 
src="https://user-images.githubusercontent.com/11539188/101954100-d3bad900-3bfb-11eb-9548-a38047b7a2d9.png";>
   <img width="1293" alt="Default__-zsh__and_airflow_–_simple_table_py" 
src="https://user-images.githubusercontent.com/11539188/101954105-d6b5c980-3bfb-11eb-82c2-86df3f244466.png";>
   
   ### CLI Output AFTER This Fix (command `airflow connections list -o 
[json|yaml]`)
   
   <img width="344" alt="Default__-zsh_-2" 
src="https://user-images.githubusercontent.com/11539188/101954146-e46b4f00-3bfb-11eb-9fac-1cc265b284d2.png";>
   <img width="1319" 
alt="Default__-zsh__and_airflow_simple_table_py_at_master_·_apache_airflow" 
src="https://user-images.githubusercontent.com/11539188/101954157-e6351280-3bfb-11eb-9d56-9b6c4d1fb4fc.png";>
   
   
   
   <!--
   Thank you for contributing! Please make sure that your code changes
   are covered with tests. And in case of new features or big changes
   remember to adjust the documentation.
   
   Feel free to ping committers for the review!
   
   In case of existing issue, reference it using one of the following:
   
   closes: #ISSUE
   related: #ISSUE
   
   How to write a good git commit message:
   http://chris.beams.io/posts/git-commit/
   -->
   
   ---
   **^ Add meaningful description above**
   
   Read the **[Pull Request 
Guidelines](https://github.com/apache/airflow/blob/master/CONTRIBUTING.rst#pull-request-guidelines)**
 for more information.
   In case of fundamental code change, Airflow Improvement Proposal 
([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvements+Proposals))
 is needed.
   In case of a new dependency, check compliance with the [ASF 3rd Party 
License Policy](https://www.apache.org/legal/resolved.html#category-x).
   In case of backwards incompatible changes please leave a note in 
[UPDATING.md](https://github.com/apache/airflow/blob/master/UPDATING.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.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to