Skip to content

fix(sqllab): default PostgreSQL port to 5432 in the dynamic connection form - #43351

Merged
sadpandajoe merged 8 commits into
masterfrom
fix-postgres-dynamic-form-default-port
Aug 21, 2026
Merged

fix(sqllab): default PostgreSQL port to 5432 in the dynamic connection form#43351
sadpandajoe merged 8 commits into
masterfrom
fix-postgres-dynamic-form-default-port

Conversation

@sadpandajoe

@sadpandajoe sadpandajoe commented Aug 20, 2026

Copy link
Copy Markdown
Member

SUMMARY

The "Connect a database" dynamic form for PostgreSQL required a Port value and blocked
connecting when it was left blank, even though PostgreSQL has a well-known default port
(5432) and the SQLAlchemy-URI connection path already worked fine without specifying one.

PostgresEngineSpec inherited BasicParametersMixin's validation and URI-building logic
unmodified, which requires port unconditionally in three places: the parameters JSON
schema exposed to the frontend form, the progressive validate_parameters check, and
build_sqlalchemy_uri. None of them consulted the engine's own advertised default port.

This PR gives PostgresEngineSpec its own parameter schema/validation/URI-building
overrides (mirroring the existing pattern in ClickHouseEngineSpec) so a blank port
defaults to 5432 instead of blocking the connection, while all other validation
(host resolution, port format/range/openness when a port is supplied) is unchanged.

This optional-port behavior is inherited by every PostgresEngineSpec subclass
(CockroachDB, Greenplum, RisingWave, and both Aurora PostgreSQL variants), each
falling back to its own default via cls.metadata["default_port"].

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

N/A at PR-open time — will be added after manual verification.

TESTING INSTRUCTIONS

  1. Open + > Data > Connect database > PostgreSQL.
  2. Fill in host/username/password/database but leave Port blank.
  3. Click CONNECT — the connection should now be attempted using port 5432 instead of
    being blocked by a "missing parameter" error.
  4. Confirm an explicitly-entered port still works exactly as before, including
    port-range/format validation errors.

Automated coverage: tests/unit_tests/db_engine_specs/test_postgres.py (13 new cases
covering build_sqlalchemy_uri's port defaulting, validate_parameters's relaxed
requirement, and the relaxed parameters schema) and updated
tests/integration_tests/db_engine_specs/postgres_tests.py /
tests/integration_tests/databases/{commands_tests,api_tests}.py.

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

@codecov

codecov Bot commented Aug 20, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 80.00000% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 66.81%. Comparing base (9781254) to head (24f6e9f).
⚠️ Report is 3 commits behind head on master.

Files with missing lines Patch % Lines
superset/db_engine_specs/postgres.py 82.35% 3 Missing ⚠️
superset/db_engine_specs/base.py 66.66% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #43351      +/-   ##
==========================================
- Coverage   66.81%   66.81%   -0.01%     
==========================================
  Files        2876     2876              
  Lines      164454   164472      +18     
  Branches    37960    37961       +1     
==========================================
+ Hits       109873   109885      +12     
- Misses      52388    52393       +5     
- Partials     2193     2194       +1     
Flag Coverage Δ
hive 38.08% <55.00%> (+<0.01%) ⬆️
javascript 74.15% <ø> (ø)
mysql 57.76% <80.00%> (+<0.01%) ⬆️
postgres 57.80% <80.00%> (+<0.01%) ⬆️
presto 40.01% <55.00%> (+<0.01%) ⬆️
python 59.23% <80.00%> (+<0.01%) ⬆️
sqlite 57.49% <80.00%> (+<0.01%) ⬆️
unit 100.00% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

sadpandajoe and others added 2 commits August 20, 2026 01:07
…s from CI

CI caught two sibling test-expectation staleness issues missed in the prior
local round (a marshmallow==3.26.2/apispec==6.10.0 local mismatch vs. this
repo's pinned marshmallow==4.3.0/apispec==6.6.1 masked one of them):

- tests/integration_tests/databases/api_tests.py::test_available has its own
  hardcoded /api/v1/database/available/ snapshot; its PostgreSQL entry still
  listed port as required and was missing port's nullable:true.
- tests/integration_tests/db_engine_specs/postgres_tests.py::
  test_base_parameters_mixin asserted a top-level additionalProperties:False
  that PostgresEngineSpec.parameters_json_schema() does not actually
  produce under the pinned marshmallow/apispec versions.

Verified both fixes against the pinned versions installed locally, plus a
full regression pass of the previously-touched integration test files.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…nd test

Sibling of the two backend integration test mocks fixed previously:
DatabaseModal/index.test.tsx's fetch-mocked /api/v1/database/available/
response for PostgreSQL still listed port as required and was missing
port's nullable:true, both stale now that PostgresEngineSpec no longer
requires port. Verified byte-accurate against
PostgresEngineSpec.parameters_json_schema()'s actual output under the
repo's pinned marshmallow/apispec versions.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@sadpandajoe sadpandajoe added review:draft 🎪 ⚡ showtime-trigger-start Create new ephemeral environment for this PR labels Aug 20, 2026
@github-actions github-actions Bot added 🎪 28db79d 🚦 building 🎪 ⌛ 48h Environment expires after 48 hours (default) and removed 🎪 ⚡ showtime-trigger-start Create new ephemeral environment for this PR labels Aug 20, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🎪 Showtime is building environment on GHA for 28db79d

@github-actions

Copy link
Copy Markdown
Contributor

🎪 Showtime is building environment on GHA for fba938d

@github-actions

Copy link
Copy Markdown
Contributor

🎪 Showtime deployed environment on GHA for d06fba3

Environment: http://54.202.103.113:8080 (admin/admin)
Lifetime: 48h auto-cleanup
Updates: New commits create fresh environments automatically

…ecks

BasicParametersMixin.validate_parameters's `if not port: return errors`
treated an explicit, present port of 0 the same as a missing/blank port,
since 0 is falsy in Python -- silently skipping the int/range/is_port_open
checks for a value the schema's own Range(min=0, ...) validator accepts as
legitimate. Narrow the short-circuit to the two actual blank
representations (`None` from an omitted/null port, `""` from a cleared
HTML number input), leaving the missing-parameters detection above it
untouched (a separate, unrelated falsy-value quirk, out of scope here).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

🎪 Showtime is building environment on GHA for 9f882c9

@bito-code-review

bito-code-review Bot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Code Review Agent Run #02a9bd

Actionable Suggestions - 0
Review Details
  • Files reviewed - 2 · Commit Range: 11dfcb7..9f882c9
    • superset/db_engine_specs/base.py
    • tests/unit_tests/db_engine_specs/test_postgres.py
  • Files skipped - 0
  • Tools
    • MyPy (Static Code Analysis) - ✔︎ Successful
    • Astral Ruff (Static Code Analysis) - ✔︎ Successful
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

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 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

AI Code Review powered by Bito Logo

@bito-code-review

Copy link
Copy Markdown
Contributor

Bito Automatic Review Skipped – PR Already Merged

Bito scheduled an automatic review for this pull request, but the review was skipped because this PR was merged before the review could be run.
No action is needed if you didn't intend to review it. To get a review, you can type /review in a comment and save it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

change:backend Requires changing the backend change:frontend Requires changing the frontend data:connect:postgres Related to Postgres review:draft size/L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants