Skip to content

feat(database-modal): add validation loading state and duplicate name check#36880

Open
EnxDev wants to merge 28 commits intomasterfrom
enxdev/feat/enhance-database-modal-validation
Open

feat(database-modal): add validation loading state and duplicate name check#36880
EnxDev wants to merge 28 commits intomasterfrom
enxdev/feat/enhance-database-modal-validation

Conversation

@EnxDev
Copy link
Copy Markdown
Contributor

@EnxDev EnxDev commented Dec 31, 2025

SUMMARY

Problem
When users fill out the database connection form, they experience two UX issues:

  1. No visual feedback during validation - When a user leaves a form field (onBlur), the system validates the input in the background, but there's no loading indicator to show that validation is in progress. This leaves users uncertain whether the system is processing their input or if something is wrong.
  2. Duplicate database name errors appear too late - Users only discover that a database name is already taken after clicking the "Connect" button and the form submission fails. This forces them to go back, change the name, and try again, creating a frustrating experience.

Solution
This PR addresses both issues:

  1. Added validation loading spinner to form fields - The isValidating prop is now passed to TableCatalog, ValidatedInputField, and CommonParameters components.
    Additionally, fixed the LabeledErrorBoundInput component where hasFeedback was only set when there was an error. Changed it, so the Ant Design FormItem displays the loading spinner during validation, not just the error icon when validation fails.
  2. Added duplicate name validation to validate_parameters API - Extended the ValidateDatabaseParametersCommand.validate() method to check for duplicate database names using DatabaseDAO.validate_uniqueness() (for new databases) or DatabaseDAO.validate_update_uniqueness() (for existing databases).
    This provides real-time feedback as users type, preventing wasted time on form submissions that will fail.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

  • Before
before.mp4
  • After
Recording.2026-02-16.161719.mp4

TESTING INSTRUCTIONS

  • All tests should pass
  • See the videos above for testing instructions

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
    es new feature or API
  • Removes existing feature or API

- Add isValidating prop to TableCatalog, ValidatedInputField, and
  CommonParameters to show loading spinner during validation
- Fix LabeledErrorBoundInput hasFeedback to display spinner while
  validating, not just on errors
- Add duplicate database name validation to validate_parameters
  endpoint for real-time feedback before form submission
…oint

- Remove early return in frontend validation hook when SSH is enabled,
  allowing backend validation to run for all database parameters
- Add SSH tunnel field validation in ValidateDatabaseParametersCommand
  to validate server_address, server_port, username, and credentials
- Add DatabaseSSHTunnelValidation schema for partial SSH tunnel data
  validation without strict authentication requirements
- Add ssh_tunnel field to DatabaseValidateParametersSchema
- Parse SSH tunnel errors in frontend and display under ssh_tunnel key
- Collect database_name duplicate errors alongside parameter errors
@netlify
Copy link
Copy Markdown

netlify Bot commented Jan 13, 2026

Deploy Preview for superset-docs-preview ready!

Name Link
🔨 Latest commit cac12ed
🔍 Latest deploy log https://app.netlify.com/projects/superset-docs-preview/deploys/6991e949724dbd0008534e03
😎 Deploy Preview https://deploy-preview-36880--superset-docs-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@EnxDev EnxDev force-pushed the enxdev/feat/enhance-database-modal-validation branch 2 times, most recently from 759b6ac to 553ae99 Compare February 16, 2026 08:24
@EnxDev EnxDev force-pushed the enxdev/feat/enhance-database-modal-validation branch from 553ae99 to 0bfaf3c Compare February 16, 2026 10:22
Comment thread superset-frontend/src/views/CRUD/hooks.ts Outdated
# Collect SSH tunnel errors
ssh_tunnel_errors = self._get_ssh_tunnel_errors()
errors.extend(ssh_tunnel_errors)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we check the top line here includes the other ones? I think we must've been doing db name errors at least.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey memo what do you mean with this? I checked validate_parameters in base.py and it only validates connection parameters (host, port, username, database)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pinging on this — I checked validate_parameters in base.py and it only validates the connection parameters (host, port, username, database). The display database_name (the user-facing label) was never validated there, so the new _get_database_name_error is the only path checking uniqueness. Happy to refactor differently if you had something else in mind.

Comment thread superset/static/service-worker.js Outdated
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 27, 2026

Codecov Report

❌ Patch coverage is 51.61290% with 30 lines in your changes missing coverage. Please review.
✅ Project coverage is 63.82%. Comparing base (adfbbf1) to head (f846e10).

Files with missing lines Patch % Lines
superset/commands/database/validate.py 43.39% 26 Missing and 4 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #36880      +/-   ##
==========================================
- Coverage   63.88%   63.82%   -0.07%     
==========================================
  Files        2583     2583              
  Lines      136596   136489     -107     
  Branches    31501    31416      -85     
==========================================
- Hits        87271    87119     -152     
- Misses      47809    47850      +41     
- Partials     1516     1520       +4     
Flag Coverage Δ
hive 39.37% <27.41%> (-0.02%) ⬇️
mysql 59.05% <51.61%> (-0.01%) ⬇️
postgres 59.12% <51.61%> (-0.01%) ⬇️
presto 41.06% <27.41%> (-0.02%) ⬇️
python 60.56% <51.61%> (-0.02%) ⬇️
sqlite 58.76% <51.61%> (-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 Sentry.
📢 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.

EnxDev and others added 5 commits May 5, 2026 23:44
…onses

The blur-debounced validation can fire multiple in-flight requests as the
user types across fields. Without sequencing, an earlier request that
returns later overwrites the result of a newer one, leaving the modal
showing stale errors and keeping the Connect button disabled even after
the form is fully valid.

Track a per-call request id and only update validation state when the
response corresponds to the latest request.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
userEvent.type fires keystrokes serially through React's event system,
which races with the new debounced validation: ports rendered as number
inputs lose values mid-typing, and dynamic-form tests time out at the
20s default while tabbing between five fields. userEvent.paste also
no longer supplies a clipboardData object the Select onPaste handler can
read.

Switch the affected interactions to fireEvent.change/blur (single-shot,
no per-key validation churn) and revert the paste case to fireEvent.paste,
matching the master form. Behavior under test is unchanged.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Adds unit tests for the duplicate-database-name check (create + update
paths, plus the bypass-engine path), the SSH tunnel feature-flag and
db-port guards, and the SSH tunnel field-level error collection
(missing required fields, missing credentials, private key without
password). Brings patch coverage on commands/database/validate.py up
from ~44%.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@pull-request-size pull-request-size Bot added size/XL and removed size/L labels May 6, 2026
@EnxDev EnxDev marked this pull request as ready for review May 6, 2026 09:22
@EnxDev EnxDev requested a review from msyavuz May 6, 2026 09:23
@dosubot dosubot Bot added change:backend Requires changing the backend change:frontend Requires changing the frontend data:databases Related to database configurations and connections labels May 6, 2026
The two ``show error alerts on dynamic form`` cases relied on a single
60s ``should('not.be.disabled')`` after typing five fields, but the
``{ timeout: 60000 }`` option on ``.should()`` is not honoured the way
it is on the query — the assertion still uses the project's 8s default
and times out before the chained validation calls complete.

Match the master cadence: explicitly blur each field and wait for the
``@validateParams`` interception before moving on, so the button-state
assertion only fires once validation is settled.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Comment thread superset-frontend/src/features/databases/DatabaseModal/index.tsx Outdated
Comment thread superset/commands/database/validate.py
Comment thread superset/commands/database/validate.py Outdated
Comment thread superset/commands/database/validate.py Outdated
EnxDev and others added 2 commits May 6, 2026 12:32
When the validate_parameters request failed without a structured error
body (e.g. network drop), getValidation returned an empty object that
the caller could not distinguish from "validation passed" — and the
blur dedup cache was already updated, so the same form state would never
revalidate until the user changed a field.

Have getValidation return null on unexpected failure and only update
the snapshot cache after a usable response.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Three correctness fixes to ValidateDatabaseParametersCommand:

1. Bypass engines (bigquery, datastore, snowflake) now also surface
   database_name uniqueness errors and SSH tunnel field errors during
   progressive validation, instead of silently passing.

2. The SSH feature-flag and database-port guards now fire when the UI
   marks parameters.ssh, not just when the ssh_tunnel payload is
   non-empty — the form sends an empty tunnel object in early stages.

3. The "parameters are missing" message for SSH tunnel fields now
   interpolates the %(missing)s placeholder via gettext, so the
   response surfaces the actual missing fields instead of the literal
   token.

Adds unit tests for each branch and removes the now-unused
_validate_database_name helper.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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:databases Related to database configurations and connections packages size/XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants