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



##########
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:
       I am not convinced that we need `ast.literal_eval` here. Can you explain 
a bit more on why we need this?




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