feat: prevent Postgres connection to Redshift#38693
Conversation
✅ Deploy Preview for superset-docs-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
There was a problem hiding this comment.
Code Review Agent Run #74544c
Actionable Suggestions - 1
-
superset/db_engine_specs/postgres.py - 1
- Blind exception catch without specific type · Line 118-120
Review Details
-
Files reviewed - 2 · Commit Range:
40376db..40376db- superset/db_engine_specs/postgres.py
- tests/unit_tests/db_engine_specs/test_postgres.py
-
Files skipped - 0
-
Tools
- Whispers (Secret Scanner) - ✔︎ Successful
- Detect-secrets (Secret Scanner) - ✔︎ Successful
- MyPy (Static Code Analysis) - ✔︎ Successful
- Astral Ruff (Static Code Analysis) - ✔︎ Successful
Bito Usage Guide
Commands
Type the following command in the pull request comment and save the comment.
-
/review- 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 documentation for additional commands.
Configuration
This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at evan@preset.io.
Documentation & Help
Sequence DiagramThis PR adds two guardrails to stop users from configuring Amazon Redshift with the PostgreSQL engine spec. Superset now performs a fast hostname validation and, during connection testing, a version-based detection before allowing the connection. sequenceDiagram
participant User
participant Superset
participant PostgresSpec
participant DatabaseServer
User->>Superset: Save or test Postgres database connection
Superset->>PostgresSpec: Validate database URI host
alt Host looks like Redshift endpoint
PostgresSpec-->>User: Reject and require Redshift driver
else Host not clearly Redshift
Superset->>PostgresSpec: Mark connection test with Redshift check flag
PostgresSpec->>DatabaseServer: On connect run version query
DatabaseServer-->>PostgresSpec: Return database version text
PostgresSpec-->>User: Reject if version indicates Redshift
end
Generated by CodeAnt AI |
Code Review Agent Run #173124Actionable Suggestions - 0Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
User description
SUMMARY
While it's technically possible to connect to Amazon Redshift using
postgresql://, it makes Superset use the Postgressqlglotdialect instead of the Redshift one, resulting in incorrectly formatted queries when we need to apply RLS or manipulate the query somehow.This PR introduces 2 checks to prevent users from connecting to Amazon Redshift with the Postgres SQLAlchemy dialect/DB engine spec:
VERSION().The checks run only during the "test connection" phase, when adding or editing a DB.
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
TESTING INSTRUCTIONS
Added unit tests.
ADDITIONAL INFORMATION
CodeAnt-AI Description
Prevent connecting to Amazon Redshift using the PostgreSQL driver during DB connection tests
What Changed
Impact
✅ Clearer Redshift connection errors during DB setup✅ Fewer incorrectly transpiled queries caused by using the wrong driver✅ Shorter debug time when configuring Redshift databases💡 Usage Guide
Checking Your Pull Request
Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.
Talking to CodeAnt AI
Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:
This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.
Example
Preserve Org Learnings with CodeAnt
You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:
This helps CodeAnt AI learn and adapt to your team's coding style and standards.
Example
Retrigger review
Ask CodeAnt AI to review the PR again, by typing:
Check Your Repository Health
To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.