codeant-ai-for-open-source[bot] commented on code in PR #40450: URL: https://github.com/apache/superset/pull/40450#discussion_r3306167428
########## superset/extensions/api.py: ########## @@ -16,21 +16,43 @@ # under the License. import mimetypes from io import BytesIO +from pathlib import Path from typing import Any +from zipfile import is_zipfile, ZipFile -from flask import send_file +from flask import current_app, request, send_file from flask.wrappers import Response from flask_appbuilder.api import BaseApi, expose, protect, safe +from superset.extensions import security_manager +from superset.extensions.settings import ( + get_extension_settings, + update_extension_settings, +) Review Comment: **🔴 Architect Review — CRITICAL** The new extensions settings API imports `superset.extensions.settings` (`get_extension_settings` / `update_extension_settings`), but no such module (file or package) exists under `superset/extensions`, so importing `ExtensionsRestApi` will fail and the default-chatbot settings flow cannot function. **Suggestion:** Add and wire a concrete `superset.extensions.settings` module that implements durable storage and validation for extension settings before exposing `/api/v1/extensions/settings`, so the imports and endpoints work at runtime. [Fix in Cursor](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=073d75b4d6944b93b095de1d1c5320e8&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=073d75b4d6944b93b095de1d1c5320e8&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/extensions/api.py **Line:** 28:31 **Comment:** *CRITICAL: The new extensions settings API imports `superset.extensions.settings` (`get_extension_settings` / `update_extension_settings`), but no such module (file or package) exists under `superset/extensions`, so importing `ExtensionsRestApi` will fail and the default-chatbot settings flow cannot function. 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> ########## superset-frontend/src/extensions/ExtensionsList.tsx: ########## @@ -50,6 +67,100 @@ const ExtensionsList: FunctionComponent<ExtensionsListProps> = ({ addDangerToast, ); + // Load current active chatbot from settings on mount + useEffect(() => { + SupersetClient.get({ endpoint: '/api/v1/extensions/settings' }) + .then(({ json }) => { + setActiveChatbotId(json?.result?.active_chatbot_id ?? null); + }) + .catch(() => { + // non-fatal: leave activeChatbotId as null + }); + }, []); + + const handleUploadClick = () => { + fileInputRef.current?.click(); + }; + + const handleFileChange = (e: React.ChangeEvent<HTMLInputElement>) => { + const file = e.target.files?.[0]; + if (!file) return; + + if (!file.name.endsWith('.supx')) { + addDangerToast(t('File must have a .supx extension.')); + e.target.value = ''; + return; + } + + const formData = new FormData(); + formData.append('bundle', file); + + setUploading(true); + SupersetClient.post({ + endpoint: '/api/v1/extensions/', + body: formData, + headers: { Accept: 'application/json' }, + }) + .then(() => { + addSuccessToast(t('Extension installed successfully.')); + refreshData(); + }) + .catch( + createErrorHandler(errMsg => + addDangerToast( + t('There was an issue installing the extension: %s', errMsg), + ), + ), + ) + .finally(() => { + setUploading(false); + e.target.value = ''; + }); + }; + + const handleDelete = (extension: Extension) => { + const { publisher, name } = extension; + SupersetClient.delete({ + endpoint: `/api/v1/extensions/${publisher}/${name}`, + }).then( Review Comment: **🔴 Architect Review — CRITICAL** ExtensionsList assumes each extension row includes a `publisher` field, but the backend `build_extension_data` payload does not provide `publisher`, so the delete URL becomes `/api/v1/extensions/undefined/<name>` and the Publisher column cannot be correctly populated. **Suggestion:** Extend `build_extension_data` (and related list/get responses) to include explicit `publisher` (and `name` if needed), and keep the delete path construction based on these guaranteed fields. [Fix in Cursor](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=daa385747ab34508ae21907ee4733836&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=daa385747ab34508ae21907ee4733836&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/src/extensions/ExtensionsList.tsx **Line:** 121:125 **Comment:** *CRITICAL: ExtensionsList assumes each extension row includes a `publisher` field, but the backend `build_extension_data` payload does not provide `publisher`, so the delete URL becomes `/api/v1/extensions/undefined/<name>` and the Publisher column cannot be correctly populated. 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]
