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 2021/05/19 02:29:25 UTC

[GitHub] [airflow] MatrixManAtYrService opened a new issue #15931: `airflow connections import foo.json` fails with `AttributeError`

MatrixManAtYrService opened a new issue #15931:
URL: https://github.com/apache/airflow/issues/15931


   Apache Airflow version
   
   6f8c204
   
   Environment
   
   Configuration: Local Executor
   OS (e.g. from /etc/os-release): Mac OS 11.3
   Kernel: Darwin Kernel Version 20.4.0
   Install tools: pip install -e .
   
   
   **What happened**:
   
   Tried to import valid connection json via the cli.  Got an error:
   
   ```
   ❯ echo '{"sqlite_conn_id": {
       "conn_type": "sqlite",
       "description": "",
       "host": "localhost",
       "login": "",
       "password": null,
       "schema": "/usr/local/airflow/test.db",
       "port": null,
       "extra": ""
     }}' | jq . > connections.json
   
   ❯ airflow connections import connections.json
   Traceback (most recent call last):
     File "/Users/matt/src/airflow/venv/bin/airflow", line 33, in <module>
       sys.exit(load_entry_point('apache-airflow', 'console_scripts', 'airflow')())
     File "/Users/matt/src/airflow/airflow/__main__.py", line 40, in main
       args.func(args)
     File "/Users/matt/src/airflow/airflow/cli/cli_parser.py", line 48, in command
       return func(*args, **kwargs)
     File "/Users/matt/src/airflow/airflow/utils/cli.py", line 91, in wrapper
       return f(*args, **kwargs)
     File "/Users/matt/src/airflow/airflow/cli/commands/connection_command.py", line 244, in connections_import
       _import_helper(args.file)
     File "/Users/matt/src/airflow/airflow/cli/commands/connection_command.py", line 272, in _import_helper
       key: value for key, value in conn_values.items() if key in allowed_fields
   AttributeError: 'Connection' object has no attribute 'items'
   ```
   
   Several of the tests assume that `load_connections_dict` returns a dict of dicts
   https://github.com/apache/airflow/blob/6f8c204b21d6c01a192bda524db72517d41bf6e9/tests/cli/commands/test_connection_command.py#L790.
   
   Actually, `load_connections_dict` returns a dict of `Connection`s
   https://github.com/apache/airflow/blob/6f8c204b21d6c01a192bda524db72517d41bf6e9/airflow/secrets/local_filesystem.py#L278
   
   When we call `.items()` on the `Connection`, it fails.
   
   **What you expected to happen**:
   
   The import is sucessful.
   
   **How to reproduce it**:
   
   See commands above.
   
   **Anything else we need to know**:
   
   This commit fixes it (I think): https://github.com/MatrixManAtYrService/airflow/commit/51590596f96f079f166d6949a520c1b0a53f475a
   
   I started making a PR, but while trying to make the tests pass I started to worry that I was on the wrong path, so I made an issue instead.


-- 
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:
users@infra.apache.org