bito-code-review[bot] commented on code in PR #36684:
URL: https://github.com/apache/superset/pull/36684#discussion_r2756627284
##########
superset-frontend/playwright/helpers/api/dataset.ts:
##########
@@ -186,3 +199,30 @@ export async function apiDeleteDataset(
): Promise<APIResponse> {
return apiDelete(page, `${ENDPOINTS.DATASET}${datasetId}`, options);
}
+
+/**
+ * Duplicate a dataset via the API
+ * @param page - Playwright page instance (provides authentication context)
+ * @param datasetId - ID of the dataset to duplicate
+ * @param newName - Name for the duplicated dataset
+ * @returns Object containing the new dataset's ID (use apiGetDataset for full
details)
+ */
+export async function duplicateDataset(
+ page: Page,
+ datasetId: number,
+ newName: string,
+): Promise<{ id: number }> {
+ const response = await apiPost(page, `${ENDPOINTS.DATASET}duplicate`, {
+ base_model_id: datasetId,
+ table_name: newName,
+ });
+ const body = await response.json();
Review Comment:
<div>
<div id="suggestion">
<div id="issue"><b>Missing API response validation</b></div>
<div id="fix">
The duplicateDataset function lacks a check for response.ok() before parsing
JSON, which could cause exceptions if the API fails. Other functions in this
file, like createTestVirtualDataset, include this check for consistency.
</div>
<details>
<summary>
<b>Code suggestion</b>
</summary>
<blockquote>Check the AI-generated fix before applying</blockquote>
<div id="code">
````suggestion
});
if (!response.ok()) {
throw new Error(`Duplicate dataset API failed: ${response.status()}
${response.statusText()}`);
}
const body = await response.json();
````
</div>
</details>
</div>
<small><i>Code Review Run #819970</i></small>
</div>
---
Should Bito avoid suggestions like this for future reviews? (<a
href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>)
- [ ] Yes, avoid them
##########
superset-frontend/playwright/components/core/Textarea.ts:
##########
@@ -0,0 +1,109 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import { Locator, Page } from '@playwright/test';
+
+/**
+ * Playwright helper for interacting with HTML {@link HTMLTextAreaElement |
`<textarea>`} elements.
+ *
+ * This component wraps a Playwright {@link Locator} and provides convenience
methods for
+ * filling, clearing, and reading the value of a textarea without having to
work with
+ * locators directly.
+ *
+ * Typical usage:
+ * ```ts
+ * const textarea = new Textarea(page, 'textarea[name="description"]');
+ * await textarea.fill('Some multi-line text');
+ * const value = await textarea.getValue();
+ * ```
+ *
+ * You can also construct an instance from the `name` attribute:
+ * ```ts
+ * const textarea = Textarea.fromName(page, 'description');
+ * await textarea.clear();
+ * ```
+ */
+export class Textarea {
+ readonly page: Page;
+ private readonly locator: Locator;
+
+ constructor(page: Page, selector: string);
+ constructor(page: Page, locator: Locator);
+ constructor(page: Page, selectorOrLocator: string | Locator) {
+ this.page = page;
+ if (typeof selectorOrLocator === 'string') {
+ this.locator = page.locator(selectorOrLocator);
+ } else {
+ this.locator = selectorOrLocator;
+ }
+ }
+
+ /**
+ * Creates a Textarea from a name attribute
+ * @param page - The Playwright page
+ * @param name - The name attribute value
+ */
+ static fromName(page: Page, name: string): Textarea {
+ const locator = page.locator(`textarea[name="${name}"]`);
Review Comment:
<div>
<div id="suggestion">
<div id="issue"><b>Selector Escaping Issue</b></div>
<div id="fix">
The selector construction in fromName could fail if the name parameter
includes double quotes, as it directly interpolates without escaping. This
might cause locator errors in tests with such names.
</div>
<details>
<summary>
<b>Code suggestion</b>
</summary>
<blockquote>Check the AI-generated fix before applying</blockquote>
<div id="code">
```
- const locator = page.locator(`textarea[name=\"${name}\"]`);
+ const locator = page.locator(`textarea[name=${JSON.stringify(name)}]`);
```
</div>
</details>
</div>
<small><i>Code Review Run #819970</i></small>
</div>
---
Should Bito avoid suggestions like this for future reviews? (<a
href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>)
- [ ] Yes, avoid them
##########
superset-frontend/playwright.config.ts:
##########
@@ -117,10 +120,19 @@ export default defineConfig({
// Web server setup - disabled in CI (Flask started separately in workflow)
webServer: process.env.CI
? undefined
- : {
- command: 'curl -f http://localhost:8088/health',
- url: 'http://localhost:8088/health',
- reuseExistingServer: true,
- timeout: 5000,
- },
+ : (() => {
+ // Support custom base URL (e.g., http://localhost:9012/app/prefix/)
+ const baseUrl =
+ process.env.PLAYWRIGHT_BASE_URL || 'http://localhost:8088';
+ // Extract origin (scheme + host + port) for health check
+ // Health endpoint is always at /health regardless of app prefix
+ const healthUrl = new URL('/health', new URL(baseUrl).origin).href;
+ return {
+ // Quote URL to prevent shell injection via PLAYWRIGHT_BASE_URL
+ command: `curl -f '${healthUrl}'`,
+ url: healthUrl,
+ reuseExistingServer: true,
Review Comment:
<div>
<div id="suggestion">
<div id="issue"><b>Shell injection risk in webServer command</b></div>
<div id="fix">
The curl command uses single quotes around the healthUrl, but if
PLAYWRIGHT_BASE_URL contains single quotes, it could lead to shell injection.
Switching to double quotes prevents this since URLs typically don't contain
double quotes.
</div>
<details>
<summary>
<b>Code suggestion</b>
</summary>
<blockquote>Check the AI-generated fix before applying</blockquote>
<div id="code">
````suggestion
return {
// Quote URL to prevent shell injection via PLAYWRIGHT_BASE_URL
command: `curl -f "${healthUrl}"`,
url: healthUrl,
reuseExistingServer: true,
````
</div>
</details>
</div>
<small><i>Code Review Run #819970</i></small>
</div>
---
Should Bito avoid suggestions like this for future reviews? (<a
href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>)
- [ ] Yes, avoid them
--
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]