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


##########
superset-frontend/packages/superset-ui-core/src/components/Select/utils.tsx:
##########
@@ -250,3 +260,57 @@ export const mapOptions = (values: SelectOptionsType): 
Record<string, any>[] =>
     key: opt.value,
     ...opt,
   }));
+
+// Splits text by separators, preserving commas inside double quotes.
+// TODO(antd): drop once https://github.com/ant-design/ant-design/issues/57820 
ships.
+export function splitWithQuoteEscaping(
+  text: string,
+  separators: string[],
+): string[] {
+  const separator = separators.find(sep => text.includes(sep));
+  if (!separator) {
+    return [text];
+  }
+
+  const results: string[] = [];
+  let current = '';
+  let inQuotes = false;
+
+  for (let i = 0; i < text.length; i += 1) {
+    const char = text[i];
+
+    if (char === '"') {
+      inQuotes = !inQuotes;
+    } else if (!inQuotes && text.startsWith(separator, i)) {
+      results.push(current.trim());
+      current = '';
+      i += separator.length - 1;
+    } else {
+      current += char;

Review Comment:
   **🟠 Architect Review — HIGH**
   
   The new splitWithQuoteEscaping tokenizer treats every double quote character 
as a control marker and never includes it in the emitted tokens, so values 
containing literal double quotes (e.g. CSV-style values like `"Bob ""The 
Builder"", Inc"`) cannot be represented correctly when typed or pasted; the 
stored/compared token will have all quotes stripped and will not match 
underlying option values that include quotes.
   
   **Suggestion:** Update splitWithQuoteEscaping to treat doubled quotes inside 
a quoted region as escaped literal quotes that are preserved in the output 
token text (rather than stripping all quote characters), and add tests for 
inputs like `"Bob ""The Builder"", Inc"` to verify both token splitting and 
that the final selected value retains the intended internal quotes.
   
   
   [Fix in 
Cursor](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=85a62131c63e49a8b1dd03799cbf0347&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
 | [Fix in VSCode 
Claude](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=85a62131c63e49a8b1dd03799cbf0347&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 an **Architect / Logical Review** comment left during a code review. 
These reviews are first-class, important findings — not optional suggestions. 
Do NOT dismiss this as a 'big architectural change' just because the title says 
architect review; most of these can be resolved with a small, localized fix 
once the intent is understood.
   
   **Path:** 
superset-frontend/packages/superset-ui-core/src/components/Select/utils.tsx
   **Line:** 279:289
   **Comment:**
        *HIGH: The new splitWithQuoteEscaping tokenizer treats every double 
quote character as a control marker and never includes it in the emitted 
tokens, so values containing literal double quotes (e.g. CSV-style values like 
`"Bob ""The Builder"", Inc"`) cannot be represented correctly when typed or 
pasted; the stored/compared token will have all quotes stripped and will not 
match underlying option values that include quotes.
   
   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.
   If a suggested approach is provided above, use it as the authoritative 
instruction. If no explicit code suggestion is given, you MUST still draft and 
apply your own minimal, localized fix — do not punt back with 'no suggestion 
provided, review manually'. Keep the change as small as possible: add a guard 
clause, gate on a loading state, reorder an await, wrap in a conditional, etc. 
Do not refactor surrounding code or expand scope beyond the finding.
   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>



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