Repository navigation
Show a clear error when a connection's database driver isn't installed - #713
Merged
Merged
Conversation
Previously, a connection whose engine driver wasn't installed (e.g. MySQL
without mysqlclient) could be saved, and then the schema pane, schema JSON,
"Test connection" and query runs all failed with a 500 because load_backend's
ImproperlyConfigured escaped. Unreachable databases had the same problem in the
schema pane.
- as_django_connection converts a missing driver into a DatabaseError that
names the package to install, so existing DatabaseError handling shows it.
- The connection form refuses engines whose driver can't be loaded, and labels
them "(driver not installed)" in the dropdown.
- The schema pane renders schema_error.html with the error instead of a 500.
- schema_json_info returns {} on failure (returning [] made JsonResponse raise).
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
A connection whose engine driver isn't installed (for example MySQL without
mysqlclient) could be saved. After that, everything that touched it failed with a blank 500:X-Frame-Options: DENYinside the iframeschema.jsonThe cause:
load_backend()raisesImproperlyConfigured, butas_django_connection()only caughtDatabaseError. An unreachable database also 500'd the schema pane, becauseSchemaViewdidn't catch theOperationalError.We found this on demo.sqlexplorer.io, where a visitor had added a MySQL connection.
Changes
as_django_connection()turns a missing driver into aDatabaseErrorthat names the package to install. The existingDatabaseErrorhandling then shows it for query runs and Test connection.DatabaseConnectionFormrefuses to save an engine whose driver can't be loaded, and labels those engines "(driver not installed)" in the dropdown. Test connection shows the specific message instead of "Invalid form data".SchemaViewrenders the existingschema_error.htmlwith the actual error, instead of a 500.schema_json_info()returns{}on failure. It used to return[], which madeJsonResponseraise, so the existingInvalidExplorerConnectionExceptionpath also 500'd.Testing
explorer.tests.settingsand undersettings_base(50 skipped).ruff==0.16.8 check exploreris clean.mysqlclientwith no mocks:SAMEORIGINand shows the install hint{}🤖 Generated with Claude Code