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


##########
superset/common/query_context_processor.py:
##########
@@ -568,7 +569,10 @@ def get_data(
                 )
             return result or ""
 
-        return df.to_dict(orient="records")
+        # QueryObject post-processing has completed before this materialization
+        # boundary. Canonicalize its trusted missing/non-finite scalar outputs,
+        # while downstream envelope validation still rejects injected infinity.
+        return df_to_records(df, convert_big_integers=False)

Review Comment:
   **Suggestion:** Disabling big-integer conversion makes chart JSON expose 
integers beyond JavaScript's safe range, so browser clients can silently lose 
precision. [logic error]
   
   **Assessment:** ๐ŸŸ  `Major` ยท ๐Ÿ” `Occurrence: Sometimes`
   
   [![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=13440bd51ff6482893e9eb479c8c1581&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=13440bd51ff6482893e9eb479c8c1581&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/common/query_context_processor.py
   **Line:** 575:575
   **Comment:**
        *Logic Error: Disabling big-integer conversion makes chart JSON expose 
integers beyond JavaScript's safe range, so browser clients can silently lose 
precision.
   
   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%2F44219&comment_hash=363357572b22f5f824e1109dac880981f75be99a6e1bc19ab5649b79dafc4b3e&reaction=like'>๐Ÿ‘</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F44219&comment_hash=363357572b22f5f824e1109dac880981f75be99a6e1bc19ab5649b79dafc4b3e&reaction=dislike'>๐Ÿ‘Ž</a>



##########
superset/dataframe.py:
##########
@@ -34,45 +43,54 @@ def _convert_big_integers(val: Any) -> Any:
     :returns: the same value but recast as a string if it was an integer over
         ``JS_MAX_INTEGER``
     """
-    return str(val) if isinstance(val, int) and abs(val) > JS_MAX_INTEGER else 
val
-
-
-def _is_na(val: Any) -> bool:
-    """
-    Check if a value is NA/NaN for scalar values only.
-
-    pd.isna() raises ValueError for arrays/lists, so we catch that case.
-
-    :param val: the value to check
-    :returns: True if the value is NA/NaN, False otherwise
-    """
-    try:
-        return bool(pd.isna(val))
-    except ValueError:
-        # pd.isna raises ValueError for arrays (e.g., lists, dicts from JSON)
-        return False
-
-
-def df_to_records(dframe: pd.DataFrame) -> list[dict[str, Any]]:
+    return str(val) if type(val) is int and abs(val) > JS_MAX_INTEGER else val
+
+
+def _is_trusted_missing_or_nonfinite(value: Any) -> bool:
+    """Recognize producer nulls without consulting object-column hooks."""
+    value_type = type(value)
+    if value_type in _PANDAS_MISSING_TYPES:
+        return True
+    if value_type is Decimal:
+        return not Decimal.is_finite(value)
+    if value_type is float:
+        return not math.isfinite(value)
+    if value_type in _NUMPY_FLOAT_TYPES:
+        return not math.isfinite(float(value))

Review Comment:
   **Suggestion:** Converting `np.longdouble` to `float` can turn a finite 
value above Python's range into infinity, causing valid large results to become 
null. [type error]
   
   **Assessment:** ๐ŸŸ  `Major` ยท ๐Ÿ” `Occurrence: Rarely`
   
   [![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=5dad234173f54b2e96224baa1c2242ec&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=5dad234173f54b2e96224baa1c2242ec&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/dataframe.py
   **Line:** 58:59
   **Comment:**
        *Type Error: Converting `np.longdouble` to `float` can turn a finite 
value above Python's range into infinity, causing valid large results to become 
null.
   
   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%2F44219&comment_hash=2494d9ac036a03666e36c636bd4658a6063c6146350c0f211a7ba66af7c9e6e2&reaction=like'>๐Ÿ‘</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F44219&comment_hash=2494d9ac036a03666e36c636bd4658a6063c6146350c0f211a7ba66af7c9e6e2&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]

Reply via email to