codeant-ai-for-open-source[bot] commented on code in PR #46037:
URL: https://github.com/apache/superset/pull/46037#discussion_r4480210080


##########
superset/dashboards/refresh_policy.py:
##########
@@ -0,0 +1,328 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+"""Server-side checks for a dashboard's ``auto_refresh_policy``."""
+
+from __future__ import annotations
+
+import math
+import re
+from dataclasses import dataclass
+from typing import Any
+
+from flask import current_app
+from flask_babel import gettext as __, ngettext
+from flask_babel.speaklater import LazyString
+
+from superset import is_feature_enabled
+from superset.utils import json
+
+POLICY_KEY = "auto_refresh_policy"
+MIN_KEY = "minimum_refresh_interval"
+MAX_KEY = "maximum_refresh_interval"
+SWITCH_KEYS = ("auto_refresh_allowed", "custom_refresh_allowed")
+BOUND_KEYS = (MIN_KEY, MAX_KEY)
+UNIT_SECONDS = {"seconds": 1, "minutes": 60, "hours": 3600}
+
+DEFAULT_REFRESH_INTERVALS: list[float] = [
+    0,
+    10,
+    30,
+    60,
+    300,
+    1800,
+    3600,
+    21600,
+    43200,
+    86400,
+]
+
+_DECIMAL = re.compile(r"[+-]?(\d+\.?\d*|\.\d+)([eE][+-]?\d+)?", re.ASCII)
+_PREFIXED = {
+    re.compile(r"0[xX][0-9a-fA-F]+"): 16,
+    re.compile(r"0[oO][0-7]+"): 8,
+    re.compile(r"0[bB][01]+"): 2,
+}
+
+
+@dataclass(frozen=True)
+class RefreshPolicyError:
+    """A field-level policy validation failure."""
+
+    field: str
+    code: str
+    message: str
+
+
+def _to_seconds(value: Any) -> float | None:
+    """Mirror of JS ``Number()`` for the value types the frontend accepts."""
+    if isinstance(value, bool):
+        return None
+    if isinstance(value, (int, float)):
+        seconds = float(value)

Review Comment:
   **Suggestion:** A sufficiently large integer in the configured intervals 
makes `float(value)` raise `OverflowError`, causing policy validation to fail 
with a server error.
   
   **Assessment:** ๐ŸŸ  `Major` ยท ๐Ÿ” `Occurrence: Rarely` ยท ๐Ÿท๏ธ `Possible bug`
   
   [![Use CodeAnt 
Skill](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/use-codeant-skill-flat-v2.svg)](https://docs.codeant.ai/cli/resolve-pr-comments-skill)
 [![Fix in 
Cursor](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-cursor-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=259e461250b548f294dc3853547efe56&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
 [![Fix in VSCode 
Claude](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-vscode-claude-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=259e461250b548f294dc3853547efe56&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
   <details>
   <summary><b>Prompt for AI Agent ๐Ÿค– </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** superset/dashboards/refresh_policy.py
   **Line:** 75:75
   **Comment:**
        *Possible Bug: A sufficiently large integer in the configured intervals 
makes `float(value)` raise `OverflowError`, causing policy validation to fail 
with a server error.
   
   Validate the correctness of the flagged issue. If correct, How can I resolve 
this? If you propose a fix, implement it and please make it concise.
   Once fix is implemented, also check other comments on the same PR, and ask 
user if the user wants to fix the rest of the comments as well. if said yes, 
then fetch all the comments validate the correctness and implement a minimal fix
   ```
   </details>
   <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F46037&comment_hash=99db8b9a35240b4f13dbc71b30f6af5acf476a4c4ca19265d5e510dbfc60db10&reaction=like'>๐Ÿ‘</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F46037&comment_hash=99db8b9a35240b4f13dbc71b30f6af5acf476a4c4ca19265d5e510dbfc60db10&reaction=dislike'>๐Ÿ‘Ž</a>



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

  • [PR] feat(d... DamianPendrak (via GitHub) via notifications
    • Re: [P... codeant-ai-for-open-source[bot] (via GitHub) via notifications
    • Re: [P... codeant-ai-for-open-source[bot] (via GitHub) via notifications
    • Re: [P... codecov[bot] (via GitHub) via notifications
    • Re: [P... codeant-ai-for-open-source[bot] (via GitHub) via notifications
    • Re: [P... codeant-ai-for-open-source[bot] (via GitHub) via notifications
    • Re: [P... codeant-ai-for-open-source[bot] (via GitHub) via notifications
    • Re: [P... netlify[bot] (via GitHub) via notifications
    • Re: [P... codeant-ai-for-open-source[bot] (via GitHub) via notifications

Reply via email to