mik-laj commented on pull request #9549:
URL: https://github.com/apache/airflow/pull/9549#issuecomment-650948525


   What do you think about this change? The error message will now contain 
extra and extra_dejson keys.
   ```patch
   From 16b5a7587f5190829f83fdea81493fd001a63ff2 Mon Sep 17 00:00:00 2001
   From: =?UTF-8?q?Kamil=20Bregu=C5=82a?= <kamil.breg...@polidea.com>
   Date: Mon, 29 Jun 2020 08:21:01 +0200
   Subject: Accept extra_json parameter in LocalFilesystemBackend
   
   ---
    airflow/secrets/local_filesystem.py | 10 +++++++++-
    1 file changed, 9 insertions(+), 1 deletion(-)
   
   diff --git a/airflow/secrets/local_filesystem.py 
b/airflow/secrets/local_filesystem.py
   index 90f565c86..3a94da1e0 100644
   --- a/airflow/secrets/local_filesystem.py
   +++ b/airflow/secrets/local_filesystem.py
   @@ -180,7 +180,7 @@ def _create_connection(conn_id: str, value: Any):
        if isinstance(value, str):
            return Connection(conn_id=conn_id, uri=value)
        if isinstance(value, dict):
   -        connection_parameter_names = get_connection_parameter_names()
   +        connection_parameter_names = get_connection_parameter_names() | 
{"extra_dejson"}
            current_keys = set(value.keys())
            if not current_keys.issubset(connection_parameter_names):
                illegal_keys = current_keys - connection_parameter_names
   @@ -189,6 +189,14 @@ def _create_connection(conn_id: str, value: Any):
                    f"The object have illegal keys: {illegal_keys_list}. "
                    f"The dictionary can only contain the following keys: 
{connection_parameter_names}"
                )
   +        if "extra" in value and "extra_dejson" in value:
   +            raise AirflowException(
   +                "The extra and extra_dejson parameters are mutually 
exclusive. "
   +                "Please provide only one parameter."
   +            )
   +        if "extra_dejson" in value:
   +            value["extra"] = json.dumps(value["extra_dejson"])
   +            del value["extra_dejson"]
    
            if "conn_id" in current_keys and conn_id != value["conn_id"]:
                raise AirflowException(
   -- 
   2.20.1
   
   ```


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


Reply via email to