This is an automated email from the ASF dual-hosted git repository. jhtimmins pushed a commit to branch v2-1-test in repository https://gitbox.apache.org/repos/asf/airflow.git
commit 1aa156a3635092b072809d50b8883430858ab16b Author: Emil Ejbyfeldt <eejbyfe...@liveintent.com> AuthorDate: Thu Jul 1 09:24:16 2021 +0200 Fix unchecked indexing in _build_metrics (#16744) I am not sure if this can happend in regular uses, but when running test cases `sys.argv` can be that args passed to the pytest. When this is the case it is definently possible for argv to only contain a single element. (cherry picked from commit a2d6aa07c9de83278eef14a228eb4a02ad43205c) --- airflow/utils/cli.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/airflow/utils/cli.py b/airflow/utils/cli.py index 2b5eb59..acdb291 100644 --- a/airflow/utils/cli.py +++ b/airflow/utils/cli.py @@ -115,7 +115,8 @@ def _build_metrics(func_name, namespace): sub_commands_to_check = {'users', 'connections'} sensitive_fields = {'-p', '--password', '--conn-password'} full_command = list(sys.argv) - if full_command[1] in sub_commands_to_check: + sub_command = full_command[1] if len(full_command) > 1 else None + if sub_command in sub_commands_to_check: for idx, command in enumerate(full_command): if command in sensitive_fields: # For cases when password is passed as "--password xyz" (with space between key and value)