uranusjr commented on a change in pull request #20174:
URL: https://github.com/apache/airflow/pull/20174#discussion_r769243345



##########
File path: airflow/models/param.py
##########
@@ -49,10 +51,28 @@ def __init__(self, default: Any = NOTSET, description: 
Optional[str] = None, **k
         self.description = description
         self.schema = kwargs.pop('schema') if 'schema' in kwargs else kwargs
 
+        if self.has_value:
+            self._validate(self.value, self.schema)
+
+    @staticmethod
+    def _validate(value, schema):
+        """
+        1. Check that value is json-serializable; if not, warn.  In future 
release we will require
+        the value to be json-serializable.
+        2. Validate ``value`` against ``schema``
+        """
+        try:
+            json.dumps(value)
+        except Exception:
+            warnings.warn(
+                "The use of non-json-serializable params is deprecated and 
will be removed in "
+                " a future release",
+                DeprecationWarning,
+            )

Review comment:
       ```suggestion
               warnings.warn(
                   "The use of non-json-serializable params is deprecated and 
will be removed in "
                   "a future release",
                   DeprecationWarning,
               )
   ```
   
   Also I think we should add `stacklevel` to make the warning show where the 
user defines the params.




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

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to