mik-laj commented on a change in pull request #9431:
URL: https://github.com/apache/airflow/pull/9431#discussion_r443191039



##########
File path: airflow/api_connexion/parameters.py
##########
@@ -48,6 +45,27 @@ def format_datetime(value: str):
         )
 
 
+def check_limit(value: int):
+    """
+    This checks the limit passed to view and raises BadRequest if
+    limit exceed user configured value
+    """
+    max_val = int(conf.get("api", "maximum_page_limit"))
+    spec = {'default': 100, 'maximum': max_val,
+            'minimum': 1, 'type': 'integer'}
+    if value > max_val:
+        # This message should not be formatted. If formatted please
+        # run tests
+        message = ("{value} is greater than the maximum of {max_val}\n"
+                   "\n"
+                   "Failed validating 'maximum' in schema:\n"
+                   "    {spec}\n"
+                   "\nOn instance:\n    {value}").format(value=value,
+                                                         max_val=max_val, 
spec=spec)

Review comment:
       ```suggestion
           message = (f"{value} is greater than the maximum of {max_val}")
   ```
   This error is not due to schema validation. We have security on another 
layer.




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