You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "eschutho (via GitHub)" <gi...@apache.org> on 2026/09/15 05:21:35 UTC

[PR] feat(trino): add dynamic connection form for Trino [superset]

eschutho opened a new pull request, #44282:
URL: https://github.com/apache/superset/pull/44282

   ### SUMMARY
   
   Part of epic [sc-120993](https://app.shortcut.com/preset/story/120993) — migrating DB connections to the new dynamic connection form. Story: https://app.shortcut.com/preset/story/121000
   
   `TrinoEngineSpec` previously had no `parameters_schema`, so adding a Trino
   database showed the raw SQLAlchemy-URI box. This adds the dynamic ("new")
   connection form to Trino **only** by mixing in `BasicParametersMixin`.
   `/api/v1/database/available/` now returns dynamic form params (host, port,
   username, optional password, catalog, and an http/https encryption toggle)
   for the `trino` engine. `PrestoEngineSpec` / presto behavior is untouched.
   
   Design decisions / notes:
   
   - **`default_driver = "rest"`**: Trino's SQLAlchemy dialect registers a
     single `trino` dialect whose reported `driver` is `rest`. The `/available/`
     endpoint only advertises the form when `default_driver` is in the set of
     installed drivers, so it must be `"rest"`. However `trino+rest://` is **not**
     a loadable SQLAlchemy plugin, so `build_sqlalchemy_uri` is overridden to
     build a driverless `trino://` URI.
   - **Catalog mapping**: the Trino URI is `trino://user[:password]@host:port/catalog[/schema]`;
     the form's `database` field maps to the catalog (relabeled "Catalog name"
     via `TrinoParametersSchema`). This is compatible with the existing
     `adjust_engine_params` / `get_default_catalog` catalog-splitting logic in
     `PrestoBaseEngineSpec`.
   - **Encryption / http-https toggle**: the Trino dialect reads the scheme from
     `connect_args["http_scheme"]`, not from the URI. The toggle is round-tripped
     through a `protocol=https` query parameter (`encryption_parameters`) and
     translated into `connect_args["http_scheme"]` in `adjust_engine_params`
     (using `setdefault`, so an existing `http_scheme` from a server cert wins).
   - **Auth**: username is required, password optional; when a password is set the
     base mixin builds `trino://user:password@...`, which the dialect maps to
     `BasicAuthentication`.
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   
   N/A — API/engine-spec change. Verified `/available/` advertises the form and
   the generated JSON schema (see testing instructions).
   
   ### TESTING INSTRUCTIONS
   
   - `pytest tests/unit_tests/db_engine_specs/test_trino.py` (125 passing,
     including new tests for `build_sqlalchemy_uri`, encryption round-trip and
     `adjust_engine_params` http_scheme translation).
   - Manually: add a new Trino database in the UI — the dynamic form now appears
     instead of the SQLAlchemy-URI box; the "Encrypt" toggle produces an
     `https` connection.
   
   ### ADDITIONAL INFORMATION
   - [ ] Has associated issue:
   - [ ] Required feature flags:
   - [ ] Changes UI
   - [ ] Includes DB Migration (follow approval process in [SIP-59](https://github.com/apache/superset/issues/13351))
   - [x] Introduces new feature or API
   - [ ] Removes existing feature or API
   


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] feat(trino): add dynamic connection form for Trino [superset]

Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #44282:
URL: https://github.com/apache/superset/pull/44282#issuecomment-5675331262

   ## [Codecov](https://app.codecov.io/gh/apache/superset/pull/44282?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
   :white_check_mark: All modified and coverable lines are covered by tests.
   :white_check_mark: Project coverage is 75.91%. Comparing base ([`b6de64f`](https://app.codecov.io/gh/apache/superset/commit/b6de64fce749f9d537a32893ef957a70b0b4cb25?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`414c518`](https://app.codecov.io/gh/apache/superset/commit/414c518fc126a6ca6ab05cf12c6ec7c5a5f9207a?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
   :warning: Report is 1 commits behind head on master.
   
   <details><summary>Additional details and impacted files</summary>
   
   
   
   ```diff
   @@           Coverage Diff           @@
   ##           master   #44282   +/-   ##
   =======================================
     Coverage   75.91%   75.91%           
   =======================================
     Files        2926     2926           
     Lines      173023   173042   +19     
     Branches    40139    40141    +2     
   =======================================
   + Hits       131351   131368   +17     
   - Misses      38993    38995    +2     
     Partials     2679     2679           
   ```
   
   | [Flag](https://app.codecov.io/gh/apache/superset/pull/44282/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
   |---|---|---|
   | [python](https://app.codecov.io/gh/apache/superset/pull/44282/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `76.14% <100.00%> (+<0.01%)` | :arrow_up: |
   | [unit](https://app.codecov.io/gh/apache/superset/pull/44282/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `76.14% <100.00%> (+<0.01%)` | :arrow_up: |
   
   Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#carryforward-flags-in-the-pull-request-comment) to find out more.
   </details>
   
   [:umbrella: View full report in Codecov by Harness](https://app.codecov.io/gh/apache/superset/pull/44282?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).   
   :loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
   <details><summary> :rocket: New features to boost your workflow: </summary>
   
   - :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
   - :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
   </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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] feat(trino): add dynamic connection form for Trino [superset]

Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #44282:
URL: https://github.com/apache/superset/pull/44282#issuecomment-5689101278

   AI Code Review is in progress (usually takes 3 to 15 minutes unless it's a very large PR).
   
   <details>
   <summary>
   Bito Usage Guide
   </summary>
   
   **Commands**
         
   Type the following command in the pull request comment and save the comment.
         
   - `/review` - Manually triggers an incremental AI Review.
   - `/review full` - Manually triggers a full AI Review.
   
   - `/pause` - Pauses automatic reviews on this pull request.
   - `/resume` - Resumes automatic reviews.
   - `/resolve` - Marks all Bito-posted review comments as resolved.
   - `/abort` - Cancels all in-progress reviews.
   
         
   Refer to the <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/available-commands" target="_blank" rel="noopener noreferrer">documentation</a> for additional commands.
         
   **Configuration**
   
   This repository uses `Superset` You can customize the agent settings <a href="https://alpha.bito.ai/home/ai-agents/code-review-agent" target="_blank" rel="noopener noreferrer">here</a> or contact your Bito workspace admin at evan@preset.io.
         
   **Documentation & Help**
   - <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/getting-started/install-run-using-bito-cloud/create-or-customize-an-agent-instance" target="_blank" rel="noopener noreferrer">Customize agent settings</a>
   - <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/implementing-custom-code-review-rules" target="_blank" rel="noopener noreferrer">Review rules</a>
   - <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent" target="_blank" rel="noopener noreferrer">General documentation</a>
   - <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/faqs" target="_blank" rel="noopener noreferrer">FAQ</a>
   
   </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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] feat(trino): add dynamic connection form for Trino [superset]

Posted by "netlify[bot] (via GitHub)" <gi...@apache.org>.
netlify[bot] commented on PR #44282:
URL: https://github.com/apache/superset/pull/44282#issuecomment-5687033914

   ### <span aria-hidden="true">✅</span> Deploy Preview for *superset-docs-preview* ready!
   
   
   |  Name | Link |
   |:-:|------------------------|
   |<span aria-hidden="true">🔨</span> Latest commit | fd902aae79346389afdffafafd71613386c601c2 |
   |<span aria-hidden="true">🔍</span> Latest deploy log | https://app.netlify.com/projects/superset-docs-preview/deploys/6aa99e6afa3bef0008c7e845 |
   |<span aria-hidden="true">😎</span> Deploy Preview | [https://deploy-preview-44282--superset-docs-preview.netlify.app](https://deploy-preview-44282--superset-docs-preview.netlify.app) |
   |<span aria-hidden="true">📱</span> Preview on mobile | <details><summary> Toggle QR Code... </summary><br /><br />![QR Code](https://app.netlify.com/qr-code/eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1cmwiOiJodHRwczovL2RlcGxveS1wcmV2aWV3LTQ0MjgyLS1zdXBlcnNldC1kb2NzLXByZXZpZXcubmV0bGlmeS5hcHAifQ.aGk0OBm6VPWQ0LAoYtzDR-i5HzCpYcMqFiJNztzoVyc)<br /><br />_Use your smartphone camera to open QR code link._</details> |
   |<span aria-hidden="true">🤖</span> Make changes | [Run an agent on this branch](https://app.netlify.com/projects/superset-docs-preview/agent-runs#q1YqKMrPLShRslJS0lFKKkrMS84AsouTdQ2NDA0MDHRLijLz8nXzUst10_KLcoFqUlILcvIrPVOAqswSEy0tU80S0xKNk1LTgKotks1TLUxMlWoB) |
   ---
   <!-- [superset-docs-preview Preview](https://deploy-preview-44282--superset-docs-preview.netlify.app) -->
   _To edit notification comments on pull requests, go to your [Netlify project configuration](https://app.netlify.com/projects/superset-docs-preview/configuration/notifications#deploy-notifications)._


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] feat(trino): add dynamic connection form for Trino [superset]

Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on code in PR #44282:
URL: https://github.com/apache/superset/pull/44282#discussion_r4171679103


##########
superset-frontend/src/features/databases/DatabaseModal/DatabaseConnectionForm/TrinoParameters.tsx:
##########
@@ -0,0 +1,122 @@
+/**
+ * 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 { t } from '@apache-superset/core/translation';
+import { SupersetTheme } from '@apache-superset/core/theme';
+import { Switch } from '@superset-ui/core/components/Switch';
+import {
+  InfoTooltip,
+  LabeledErrorBoundInput as ValidatedInput,
+} from '@superset-ui/core/components';
+import { FieldPropTypes } from '../../types';
+import { toggleStyle, infoTooltip } from '../styles';
+
+/**
+ * Trino-specific variants of the common connection form fields.
+ *
+ * In a Trino SQLAlchemy URI (``trino://user@host:port/<catalog>[/schema]``)
+ * the ``database`` component is the Trino catalog, the coordinator listens on
+ * 8080 by default (443 behind HTTPS), and the encryption toggle switches the
+ * client to HTTPS rather than setting a Postgres-style SSL mode.
+ */
+export const TRINO_ENGINE = 'trino';
+
+export const trinoCatalogField = ({
+  required,
+  changeMethods,
+  getValidation,
+  validationErrors,
+  description,
+  db,
+  isValidating,
+}: FieldPropTypes) => (
+  <ValidatedInput
+    isValidating={isValidating}
+    id="database"
+    name="database"
+    required={required}
+    value={db?.parameters?.database}
+    validationMethods={{ onBlur: getValidation }}
+    errorMessage={validationErrors?.database}
+    placeholder={t('e.g. hive')}
+    label={description || t('Catalog name')}
+    onChange={changeMethods.onParametersChange}
+    helpText={t(
+      'The Trino catalog to connect to (e.g. hive, iceberg). It is used as the database in the SQLAlchemy URI.',
+    )}
+  />
+);
+
+export const trinoPortField = ({
+  required,
+  changeMethods,
+  getValidation,
+  validationErrors,
+  db,
+  isValidating,
+}: FieldPropTypes) => (
+  <ValidatedInput
+    id="port"
+    name="port"
+    type="number"
+    isValidating={isValidating}
+    required={required}
+    value={db?.parameters?.port as number}
+    validationMethods={{ onBlur: getValidation }}
+    errorMessage={validationErrors?.port}
+    placeholder={t('e.g. 8080 (443 for HTTPS)')}
+    className="form-group-w-50"
+    label={t('Port')}
+    onChange={changeMethods.onParametersChange}
+  />
+);
+
+export const trinoEncryptionField = ({
+  isEditMode,
+  changeMethods,
+  db,
+  sslForced,
+}: FieldPropTypes) => (
+  <div css={(theme: SupersetTheme) => infoTooltip(theme)}>
+    <Switch
+      disabled={sslForced && !isEditMode}
+      checked={db?.parameters?.encryption || sslForced}
+      onChange={changed => {
+        changeMethods.onParametersChange({
+          target: {
+            type: 'toggle',
+            name: 'encryption',
+            checked: true,
+            value: changed,
+          },
+        });
+      }}
+    />
+    <span css={toggleStyle}>{t('SSL')}</span>
+    <InfoTooltip
+      tooltip={t('HTTPS will be used to connect to the Trino coordinator.')}
+      placement="right"
+    />
+  </div>
+);

Review Comment:
   <div>
   
   
   <div id="suggestion">
   <div id="issue"><b>Duplicated field components</b></div>
   <div id="fix">
   
   `trinoCatalogField`/`trinoPortField`/`trinoEncryptionField` are near-verbatim copies of `databaseField`/`portField`/`forceSSLField` in `CommonParameters.tsx`, differing only in label/placeholder/helpText. This duplication will silently diverge (e.g. a fix to `forceSSLField` won't reach `trinoEncryptionField`). Consider parameterizing the shared components instead.
   </div>
   
   
   </div>
   
   
   
   
   <small><i>Code Review Run #508611</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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] feat(trino): add dynamic connection form for Trino [superset]

Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #44282:
URL: https://github.com/apache/superset/pull/44282#issuecomment-5675218559

   <!-- Bito Reply -->
   The issue is correct. In `adjust_engine_params`, `connect_args.setdefault("http_scheme", protocol)` only sets `http_scheme` if it is not already present. If `http_scheme` is already set to `"http"` in `connect_args`, the `protocol` (e.g., `"https"`) from the URI is ignored, resulting in an unencrypted connection.
   
   To resolve this, you should use `update` or explicitly overwrite the value if the protocol is provided, ensuring the intended encryption setting takes precedence over existing `connect_args` values.
   
   ### Proposed Fix
   
   Update `superset/db_engine_specs/trino.py` as follows:
   
   ```python
           if protocol := uri.query.get("protocol"):
               uri = uri.set(
                   query={
                       key: value for key, value in uri.query.items() if key != "protocol"
                   }
               )
               connect_args["http_scheme"] = protocol
   ```
   
   Would you like me to check the other comments on this PR and implement fixes for them as well?
   
   **superset/db_engine_specs/trino.py**
   ```
   if protocol := uri.query.get("protocol"):
               uri = uri.set(
                   query={
                       key: value for key, value in uri.query.items() if key != "protocol"
                   }
               )
               connect_args["http_scheme"] = protocol
   ```


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] feat(trino): add dynamic connection form for Trino [superset]

Posted by "codeant-ai-for-open-source[bot] (via GitHub)" <gi...@apache.org>.
codeant-ai-for-open-source[bot] commented on PR #44282:
URL: https://github.com/apache/superset/pull/44282#issuecomment-6025169008

   ## CodeAnt PR Risk: High Risk
   
   - The PR should not merge yet because the Trino SSL toggle can indicate HTTPS while the connection uses plain HTTP.
   - In adjust_engine_params, setdefault preserves an existing http_scheme="http" over protocol=https, and a new test explicitly locks in that behavior.
   
   **Assessed commit:** `56b441f73e16`


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] feat(trino): add dynamic connection form for Trino [superset]

Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #44282:
URL: https://github.com/apache/superset/pull/44282#issuecomment-5675175917

   AI Code Review is in progress (usually takes 3 to 15 minutes unless it's a very large PR).


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] feat(trino): add dynamic connection form for Trino [superset]

Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #44282:
URL: https://github.com/apache/superset/pull/44282#issuecomment-5965444324

   AI Code Review is in progress (usually takes 3 to 15 minutes unless it's a very large PR).
   
   <details>
   <summary>
   Bito Usage Guide
   </summary>
   
   **Commands**
         
   Type the following command in the pull request comment and save the comment.
         
   - `/review` - Manually triggers an incremental AI Review.
   - `/review full` - Manually triggers a full AI Review.
   
   - `/pause` - Pauses automatic reviews on this pull request.
   - `/resume` - Resumes automatic reviews.
   - `/resolve` - Marks all Bito-posted review comments as resolved.
   - `/abort` - Cancels all in-progress reviews.
   
         
   Refer to the <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/available-commands" target="_blank" rel="noopener noreferrer">documentation</a> for additional commands.
         
   **Configuration**
   
   This repository uses `Superset` You can customize the agent settings <a href="https://alpha.bito.ai/home/ai-agents/code-review-agent" target="_blank" rel="noopener noreferrer">here</a> or contact your Bito workspace admin at evan@preset.io.
         
   **Documentation & Help**
   - <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/getting-started/install-run-using-bito-cloud/create-or-customize-an-agent-instance" target="_blank" rel="noopener noreferrer">Customize agent settings</a>
   - <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/implementing-custom-code-review-rules" target="_blank" rel="noopener noreferrer">Review rules</a>
   - <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent" target="_blank" rel="noopener noreferrer">General documentation</a>
   - <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/faqs" target="_blank" rel="noopener noreferrer">FAQ</a>
   
   </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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] feat(trino): add dynamic connection form for Trino [superset]

Posted by "codeant-ai-for-open-source[bot] (via GitHub)" <gi...@apache.org>.
codeant-ai-for-open-source[bot] commented on code in PR #44282:
URL: https://github.com/apache/superset/pull/44282#discussion_r4012238940


##########
superset/db_engine_specs/trino.py:
##########
@@ -182,6 +213,57 @@ class TrinoEngineSpec(PrestoBaseEngineSpec):
     supports_oauth2 = True
     oauth2_token_request_type = "data"  # noqa: S105
 
+    @classmethod
+    def build_sqlalchemy_uri(
+        cls,
+        parameters: BasicParametersType,
+        encrypted_extra: dict[str, str] | None = None,
+    ) -> str:
+        """
+        Build the SQLAlchemy URI from the dynamic form parameters.
+
+        Mirrors ``BasicParametersMixin.build_sqlalchemy_uri`` but forces the
+        driverless ``trino`` scheme: ``default_driver`` is ``rest`` only so the
+        connection form is advertised, and ``trino+rest://`` is not a loadable
+        SQLAlchemy dialect.
+        """
+        # make a copy so that we don't update the original
+        query = parameters.get("query", {}).copy()
+        if parameters.get("encryption"):
+            query.update(cls.encryption_parameters)
+
+        return URL.create(
+            cls.engine,
+            username=parameters.get("username"),
+            password=parameters.get("password"),
+            host=parameters["host"],
+            port=parameters["port"],
+            database=parameters["database"],
+            query=query,
+        ).render_as_string(hide_password=False)
+
+    @classmethod
+    def adjust_engine_params(
+        cls,
+        uri: URL,
+        connect_args: dict[str, Any],
+        catalog: str | None = None,
+        schema: str | None = None,
+    ) -> tuple[URL, dict[str, Any]]:
+        # The dynamic form's encryption toggle is stored as a ``protocol`` query
+        # parameter (see ``encryption_parameters``). The Trino dialect reads the
+        # scheme from ``connect_args["http_scheme"]``, not from the URI, so
+        # translate it here and drop the parameter from the URI.
+        if protocol := uri.query.get("protocol"):
+            uri = uri.set(
+                query={
+                    key: value for key, value in uri.query.items() if key != "protocol"
+                }
+            )
+            connect_args.setdefault("http_scheme", protocol)

Review Comment:
   **Suggestion:** When existing `connect_args` contains `http_scheme="http"`, `protocol=https` is ignored, so an encrypted form connection still uses HTTP. [security]
   
   **Assessment:** 🟠 `Major` · 🔁 `Occurrence: Sometimes`
   
   [![Use CodeAnt Skill](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/use-codeant-skill-flat-v2.svg)](https://docs.codeant.ai/cli/resolve-pr-comments-skill) [![Fix in Cursor](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-cursor-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=663843870baf4c7aa9ecd84233533781&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset) [![Fix in VSCode Claude](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-vscode-claude-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=663843870baf4c7aa9ecd84233533781&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
   <details>
   <summary><b>Prompt for AI Agent 🤖 </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** superset/db_engine_specs/trino.py
   **Line:** 263:263
   **Comment:**
   	*Security: When existing `connect_args` contains `http_scheme="http"`, `protocol=https` is ignored, so an encrypted form connection still uses HTTP.
   
   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%2F44282&comment_hash=3a96310715123b28950a71c389e1ed44596c9df4ec1dc60a297ee6a2e6fad157&reaction=like'>👍</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F44282&comment_hash=3a96310715123b28950a71c389e1ed44596c9df4ec1dc60a297ee6a2e6fad157&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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] feat(trino): add dynamic connection form for Trino [superset]

Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas commented on PR #44282:
URL: https://github.com/apache/superset/pull/44282#issuecomment-6123919479

   Thanks @eschutho, nice to see Trino get the dynamic form. However, codeant's thread on `adjust_engine_params` looks valid to me: with `setdefault`, an existing `http_scheme: "http"` in `connect_args` beats an explicit Encrypt toggle, so someone could tick the box and still go out over HTTP. Should the toggle win, or only defer when the existing value is already `https`? The test that pins the current behavior would need to change either way.
   
   The duplicated field components Bito flagged are fine by me as-is. Otherwise LGTM!


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org