korbit-ai[bot] commented on code in PR #31796: URL: https://github.com/apache/superset/pull/31796#discussion_r1919116368
########## docker/docker-entrypoint-initdb.d/cypress-init.sh: ########## @@ -0,0 +1,28 @@ +#!/usr/bin/env bash + +# 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. + +# ------------------------------------------------------------------------ +# Creates the examples database and respective user. This database location +# and access credentials are defined on the environment variables +# ------------------------------------------------------------------------ +set -e + +psql -v ON_ERROR_STOP=1 --username "${POSTGRES_USER}" <<-EOSQL Review Comment: ### Insufficient psql error feedback <sub></sub> <details> <summary>Tell me more</summary> ###### What is the issue? The script relies on set -e for error handling but doesn't capture or log potential psql errors meaningfully ###### Why this matters While ON_ERROR_STOP=1 ensures psql fails on error and set -e exits the script, there's no feedback to help diagnose what went wrong if the database creation fails ###### Suggested change ∙ *Feature Preview* Wrap the psql command in error handling to provide context: ```bash if ! psql -v ON_ERROR_STOP=1 --username "${POSTGRES_USER}" <<-EOSQL CREATE DATABASE superset_cypress; EOSQL then echo "Failed to create superset_cypress database" >&2 exit 1 fi ``` </details> ###### Chat with Korbit by mentioning @korbit-ai, and give a 👍 or 👎 to help Korbit improve your reviews. <!--- korbi internal id:f6f982fd-4a8b-41d4-b83b-0db3f2216131 --> ########## docker/pythonpath_dev/superset_config.py: ########## @@ -107,6 +108,18 @@ class CeleryConfig: log_level_text = os.getenv("SUPERSET_LOG_LEVEL", "INFO") LOG_LEVEL = getattr(logging, log_level_text.upper(), logging.INFO) +if os.getenv("CYPRESS_CONFIG") == "true": + # When running the service as a cypress backend, we need to import the config + # located @ tests/integration_tests/superset_test_config.py + base_dir = os.path.dirname(__file__) + module_folder = os.path.abspath( + os.path.join(base_dir, "../../tests/integration_tests/") + ) + sys.path.insert(0, module_folder) + from superset_test_config import * # noqa Review Comment: ### Avoid using relative and wildcard imports. <sub></sub> <details> <summary>Tell me more</summary> ​ The code is importing the 'superset_test_config' module using a relative path and executing its contents with a wildcard import ('from superset_test_config import *'). This can be a security risk as it allows the imported file to execute arbitrary code in the application's context. To mitigate this, use an absolute import path instead of a relative path, and import only the specific names needed instead of using a wildcard import. Validate the imported names to ensure they don't contain malicious code. </details> ###### Chat with Korbit by mentioning @korbit-ai, and give a 👍 or 👎 to help Korbit improve your reviews. <!--- korbi internal id:545129e9-1741-4a4c-af65-be2ce9d28a27 --> ########## docker/docker-entrypoint-initdb.d/cypress-init.sh: ########## @@ -0,0 +1,28 @@ +#!/usr/bin/env bash + +# 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. + +# ------------------------------------------------------------------------ +# Creates the examples database and respective user. This database location +# and access credentials are defined on the environment variables +# ------------------------------------------------------------------------ +set -e + +psql -v ON_ERROR_STOP=1 --username "${POSTGRES_USER}" <<-EOSQL + CREATE DATABASE superset_cypress; +EOSQL Review Comment: ### Missing Database Permissions <sub></sub> <details> <summary>Tell me more</summary> ###### What is the issue? The script creates a database but doesn't grant necessary permissions to access it, which is required for Cypress tests to function properly. ###### Why this matters Without proper permissions, the Cypress tests will fail when attempting to connect to or interact with the database, leading to test failures. ###### Suggested change ∙ *Feature Preview* Add GRANT statements to provide necessary permissions for the database. Example: ```sql psql -v ON_ERROR_STOP=1 --username "${POSTGRES_USER}" <<-EOSQL CREATE DATABASE superset_cypress; GRANT ALL PRIVILEGES ON DATABASE superset_cypress TO "${POSTGRES_USER}"; EOSQL ``` </details> ###### Chat with Korbit by mentioning @korbit-ai, and give a 👍 or 👎 to help Korbit improve your reviews. <!--- korbi internal id:2322dd80-f469-4f84-8a31-6dae664e5323 --> ########## superset-frontend/cypress-base/cypress/e2e/explore/utils.ts: ########## @@ -68,7 +72,10 @@ export function saveChartToDashboard(dashboardName: string) { interceptUpdate(); interceptExploreGet(); - cy.getBySel('query-save-button').click(); + cy.getBySel('query-save-button') + .should('be.enabled') + .should('not.be.disabled') + .click(); Review Comment: ### Redundant Button State Assertions <sub></sub> <details> <summary>Tell me more</summary> ###### What is the issue? Redundant assertion checking for both 'be.enabled' and 'not.be.disabled' on the save button. These assertions are functionally equivalent in Cypress. ###### Why this matters Using redundant assertions increases test execution time and adds unnecessary complexity to the test code without providing additional verification value. ###### Suggested change ∙ *Feature Preview* Use only one assertion to check the button state: ```typescript cy.getBySel('query-save-button') .should('be.enabled') .click(); ``` </details> ###### Chat with Korbit by mentioning @korbit-ai, and give a 👍 or 👎 to help Korbit improve your reviews. <!--- korbi internal id:d649f57c-efa3-48dc-b588-90783562974b --> ########## docker/docker-entrypoint-initdb.d/cypress-init.sh: ########## @@ -0,0 +1,28 @@ +#!/usr/bin/env bash + +# 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. + +# ------------------------------------------------------------------------ +# Creates the examples database and respective user. This database location +# and access credentials are defined on the environment variables Review Comment: ### Missing Environment Variable Validation <sub></sub> <details> <summary>Tell me more</summary> ###### What is the issue? The script comment mentions credentials being defined in environment variables, but the script doesn't validate their presence. ###### Why this matters If required environment variables are not set, the script will fail silently or with unclear errors, causing initialization issues. ###### Suggested change ∙ *Feature Preview* Add environment variable validation at the beginning of the script: ```bash if [ -z "${POSTGRES_USER}" ]; then echo "Error: POSTGRES_USER environment variable is not set" exit 1 fi ``` </details> ###### Chat with Korbit by mentioning @korbit-ai, and give a 👍 or 👎 to help Korbit improve your reviews. <!--- korbi internal id:e9abfc9c-4068-4314-8040-cd02392a49f2 --> -- 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]
