xinbinhuang commented on a change in pull request #15104:
URL: https://github.com/apache/airflow/pull/15104#discussion_r606089064



##########
File path: airflow/providers/amazon/aws/secrets/secrets_manager.py
##########
@@ -102,17 +102,66 @@ def client(self):
         )
         return session.client(service_name="secretsmanager", **self.kwargs)
 
-    def get_conn_uri(self, conn_id: str) -> Optional[str]:
+    def _get_extra(self, secret, conn_string):
+        if 'extra' in secret:
+            extra_dict = ast.literal_eval(secret['extra'])
+            counter = 0
+            for key, value in extra_dict.items():
+                if counter == 0:
+                    conn_string += f'?{key}={value}'
+                else:
+                    conn_string += f'&{key}={value}'
+
+                counter += 1
+
+        return conn_string
+
+    def get_conn_uri(self, conn_id: str):
         """
         Get Connection Value
 
         :param conn_id: connection id
         :type conn_id: str
         """
-        if self.connections_prefix is None:
-            return None
+        if self.connections_prefix and self.sep:
+            conn_id = self.build_path(self.connections_prefix, conn_id, 
self.sep)
 
-        return self._get_secret(self.connections_prefix, conn_id)
+        try:
+            secret_string = self._get_secret(conn_id)
+            secret = ast.literal_eval(secret_string)  # json.loads gives error
+        except ValueError:  # 'malformed node or string: ' error, for empty 
conns
+            connection = None
+            secret = None

Review comment:
       Another note, the signature for is `_get_secret(self, path_prefix: str, 
secret_id: str)`. 
   
https://github.com/apache/airflow/blob/c651ab71d911e99d4376722611b12bc5be6eeae4/airflow/providers/amazon/aws/secrets/secrets_manager.py#L190-L200




-- 
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