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


##########
superset/utils/pandas_postprocessing/select.py:
##########
@@ -48,6 +51,16 @@ def select(
     if columns:
         df_select = df_select[columns]
     if exclude:
+        # `exclude` is validated against the incoming DataFrame by the 
decorator, but
+        # a preceding `columns` selection may already have removed the column. 
Reject
+        # that as a validation error instead of letting pandas raise a bare 
KeyError.
+        if missing := [column for column in exclude if column not in 
df_select.columns]:

Review Comment:
   **Suggestion:** The shared `scalar_to_sequence` helper deliberately accepts 
a scalar string for column arguments, so direct callers passing 
`exclude="label"` are still accepted by the decorator and pandas previously 
handled that form correctly. This list comprehension iterates the string 
character by character, reports characters such as `l` and `a` as missing, and 
rejects a valid exclusion. Normalize `exclude` with `scalar_to_sequence` before 
iterating. [api mismatch]
   
   <details>
   <summary><b>Severity Level:</b> Major ⚠️</summary>
   
   ```mdx
   - ❌ Direct scalar `select.exclude` calls now fail validation.
   - ⚠️ Shared post-processing scalar compatibility is inconsistent.
   - ⚠️ Internal utility consumers may receive unexpected 400 errors.
   ```
   </details>
   <details>
   <summary><b>Steps of Reproduction ✅ </b></summary>
   
   ```mdx
   1. Call the public `select()` utility directly with a normal DataFrame and
   `exclude="label"`; the shared helper at
   `superset/utils/pandas_postprocessing/utils.py:115-121` explicitly 
normalizes scalar
   strings to one-element sequences.
   
   2. The decorator therefore accepts the scalar and invokes `select()` with 
the original
   string at `superset/utils/pandas_postprocessing/utils.py:123-139`.
   
   3. `select()` reaches `superset/utils/pandas_postprocessing/select.py:57`, 
where iterating
   `exclude` processes `l`, `a`, `b`, `e`, and `l` rather than the single 
column name
   `label`.
   
   4. The characters are absent from the DataFrame columns, so 
`InvalidPostProcessingError`
   is raised instead of excluding `label`; the chart-data schema normally 
declares `exclude`
   as a list at `superset/charts/schemas.py:658-663`, but direct utility 
callers and the
   shared scalar-accepting decorator contract still expose this regression.
   ```
   </details>
   
   [![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=f3cd754cf66a44f6a6df2f5c2283018e&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=f3cd754cf66a44f6a6df2f5c2283018e&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
   
   *(Use Cmd/Ctrl + Click for best experience)*
   <details>
   <summary><b>Prompt for AI Agent 🤖 </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** superset/utils/pandas_postprocessing/select.py
   **Line:** 57:57
   **Comment:**
        *Api Mismatch: The shared `scalar_to_sequence` helper deliberately 
accepts a scalar string for column arguments, so direct callers passing 
`exclude="label"` are still accepted by the decorator and pandas previously 
handled that form correctly. This list comprehension iterates the string 
character by character, reports characters such as `l` and `a` as missing, and 
rejects a valid exclusion. Normalize `exclude` with `scalar_to_sequence` before 
iterating.
   
   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%2F42410&comment_hash=c0afa3a763d1fb0c787cb82c04581b76e0d9a31495fb519a8193b64895b1c3e2&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F42410&comment_hash=c0afa3a763d1fb0c787cb82c04581b76e0d9a31495fb519a8193b64895b1c3e2&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