bito-code-review[bot] commented on code in PR #36933: URL: https://github.com/apache/superset/pull/36933#discussion_r2669891286
########## docs/docs/configuration/databases.mdx: ########## @@ -1137,6 +1194,28 @@ More information about PostgreSQL connection options can be found in the and the [PostgreSQL docs](https://www.postgresql.org/docs/9.1/libpq-connect.html#LIBPQ-PQCONNECTDBPARAMS). +:::resources +- [Blog: Data Visualization in PostgreSQL With Apache Superset](https://www.tigerdata.com/blog/data-visualization-in-postgresql-with-apache-superset) +::: + +#### QuestDB + +[QuestDB](https://questdb.io/) is a high-performance, open-source time-series database with SQL support. +The recommended connector library is the PostgreSQL driver [psycopg2](https://www.psycopg.org/docs/), +as QuestDB supports the PostgreSQL wire protocol. + +The connection string is formatted as follows: + +``` +postgresql+psycopg2://{username}:{password}@{hostname}:{port}/{database} +``` + +The default port for QuestDB's PostgreSQL interface is `8812`. + +:::resources +- [QuestDB Docs: Apache Superset Integration](https://questdb.com/docs/third-party-tools/superset/) Review Comment: <div> <div id="suggestion"> <div id="issue"><b>Broken Documentation Link</b></div> <div id="fix"> The link to QuestDB's Superset integration docs returns a 404 error. Please verify and update to the current valid URL, as broken links reduce documentation usability. </div> </div> <small><i>Code Review Run #e3850d</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/embedded_chart/view.py: ########## @@ -0,0 +1,116 @@ +# 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 logging +from typing import Any, Callable, cast + +from flask import abort, current_app, request +from flask_appbuilder import expose +from flask_login import AnonymousUserMixin, login_user +from flask_wtf.csrf import same_origin + +from superset import event_logger, is_feature_enabled +from superset.commands.explore.permalink.get import GetExplorePermalinkCommand +from superset.superset_typing import FlaskResponse +from superset.utils import json +from superset.views.base import BaseSupersetView, common_bootstrap_payload + +logger = logging.getLogger(__name__) + + +class EmbeddedChartView(BaseSupersetView): + """Server-side rendering for embedded chart pages.""" + + route_base = "/embedded/chart" + + @expose("/") + @event_logger.log_this_with_extra_payload + def embedded_chart( + self, + add_extra_log_payload: Callable[..., None] = lambda **kwargs: None, + ) -> FlaskResponse: + """ + Server side rendering for the embedded chart page. + Expects ?permalink_key=xxx query parameter. + """ + if not is_feature_enabled("EMBEDDABLE_CHARTS_MCP"): + abort(404) + + # Get permalink_key from query params + permalink_key = request.args.get("permalink_key") + if not permalink_key: + logger.warning("Missing permalink_key in embedded chart request") + abort(404) + + # Fetch permalink to get allowed_domains for referrer validation + try: + permalink_value = GetExplorePermalinkCommand(permalink_key).run() + except Exception: + logger.exception("Error fetching permalink for embedded chart") + permalink_value = None + + if not permalink_value: + logger.warning("Permalink not found for embedded chart: %s", permalink_key) + abort(404) + + assert permalink_value is not None # for mypy Review Comment: <div> <div id="suggestion"> <div id="issue"><b>Use of assert statement detected</b></div> <div id="fix"> Replace `assert` statement with explicit error handling. Use a conditional check and `abort()` or raise an exception instead of `assert` for production code. </div> <details> <summary> <b>Code suggestion</b> </summary> <blockquote>Check the AI-generated fix before applying</blockquote> <div id="code"> ````suggestion if permalink_value is None: abort(500) # permalink_value is guaranteed to be not None for mypy ```` </div> </details> </div> <small><i>Code Review Run #e3850d</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]
