codeant-ai-for-open-source[bot] commented on code in PR #41199:
URL: https://github.com/apache/superset/pull/41199#discussion_r3452930642
##########
superset-frontend/src/SqlLab/components/EditorWrapper/useKeywords.ts:
##########
@@ -197,7 +205,7 @@ export function useKeywords(
() =>
allCachedTables.map(({ value, label, schema: tableSchema }) => ({
name: label,
- value,
+ value: quoteIdentifier(value),
Review Comment:
**Suggestion:** Using the quoted identifier as the table completion `value`
breaks downstream table metadata flows because this `value` is also passed to
`addTable` on selection. That stores names like `"COVID Vaccines"` (with
quotes) in pinned table state, and later metadata requests use that quoted
string as the `name` query param, which can fail table lookups that expect the
raw table name. Keep autocomplete insertion quoting separate from the canonical
table identity used by state/API calls. [api mismatch]
<details>
<summary><b>Severity Level:</b> Critical 🚨</summary>
```mdx
- ❌ SQL Lab table preview fails for quoted-name tables.
- ❌ Table metadata panel shows missing columns for those tables.
- ⚠️ Column autocomplete misses columns from pinned quoted tables.
```
</details>
<details>
<summary><b>Steps of Reproduction ✅ </b></summary>
```mdx
1. Open SQL Lab editor, which renders `EditorWrapper` at
`superset-frontend/src/SqlLab/components/EditorWrapper/index.tsx:104-120`
and passes
`keywords={keywords}` from `useKeywords(...)` at lines 26-35 and 382.
2. `useKeywords` builds `tableKeywords` in
`superset-frontend/src/SqlLab/components/EditorWrapper/useKeywords.ts:204-210`,
setting
each table keyword to `{ name: label, value: quoteIdentifier(value), schema:
tableSchema,
meta: 'table', completer: { insertMatch } }`, so a table like `COVID
Vaccines` produces
`value: "\"COVID Vaccines\""`.
3. In the editor, trigger autocomplete and select the `COVID Vaccines` table
completion;
Ace calls `insertMatch` defined in `useKeywords.ts:165-187`, which for
`data.meta ===
'table'` dispatches `addTable(..., data.value, catalog ?? null, data.schema
?? schema ??
'', false)` using the quoted `data.value` (`"COVID Vaccines"`) as the
`tableName`.
4. `addTable` in `superset-frontend/src/SqlLab/actions/sqlLab.ts:22-37`
stores this quoted
`tableName` as `table.name`, and later `SouthPane` at
`superset-frontend/src/SqlLab/components/SouthPane/index.tsx:82-103` passes
`tableName={name}` into `TablePreview`, which uses `tableName` as the
`table` parameter to
`useTableMetadataQuery` (`TablePreview/index.tsx:136-143`), leading
`tables.ts:14-19` to
call
`/api/v1/database/{dbId}/table_metadata/?name="%22COVID%20Vaccines%22"&schema=...`;
because the backend expects the raw table name (`COVID Vaccines`) without
quotes, metadata
lookups and previews for tables pinned via autocomplete can fail.
```
</details>
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=55d0463327954489afd99457fce67d1b&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
[](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=55d0463327954489afd99457fce67d1b&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-frontend/src/SqlLab/components/EditorWrapper/useKeywords.ts
**Line:** 208:208
**Comment:**
*Api Mismatch: Using the quoted identifier as the table completion
`value` breaks downstream table metadata flows because this `value` is also
passed to `addTable` on selection. That stores names like `"COVID Vaccines"`
(with quotes) in pinned table state, and later metadata requests use that
quoted string as the `name` query param, which can fail table lookups that
expect the raw table name. Keep autocomplete insertion quoting separate from
the canonical table identity used by state/API calls.
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%2F41199&comment_hash=de142fbb321ac4139b0415db482b8968e20f5ad537926ab8f6c11579b1311fca&reaction=like'>👍</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41199&comment_hash=de142fbb321ac4139b0415db482b8968e20f5ad537926ab8f6c11579b1311fca&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]