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/04/02 16:02:34 UTC

[GitHub] [airflow] dstandish commented on a change in pull request #15146: Validate that the extra parameter is parseable as JSON

dstandish commented on a change in pull request #15146:
URL: https://github.com/apache/airflow/pull/15146#discussion_r606302213



##########
File path: airflow/models/connection.py
##########
@@ -137,7 +137,25 @@ def __init__(  # pylint: disable=too-many-arguments
             self.password = password
             self.schema = schema
             self.port = port
-            self.extra = extra
+            self.extra = self.validate_extra(extra)
+
+    @staticmethod
+    def validate_extra(extra: str):
+        """
+        `extra` parameter is a JSON encoded object. This methods validates that the data
+        adheres to this specification.
+
+        :param extra: The extra section of the .
+        :type extra: str
+
+        :return str
+        """
+        try:
+            json.loads(extra)

Review comment:
       @mik-laj has suggested we should forbid the case where `json.loads(extra)` produces a list or primitive
   
   anyone else agree with that?




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