]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
dont render URL in unparseable URL error message
authorMike Bayer <mike_mp@zzzcomputing.com>
Thu, 8 May 2025 12:34:21 +0000 (08:34 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Thu, 8 May 2025 12:34:21 +0000 (08:34 -0400)
The error message that is emitted when a URL cannot be parsed no longer
includes the URL itself within the error message.

Fixes: #12579
Change-Id: Icd17bd4fe0930036662b6a4fe0264cb13df04ba7

doc/build/changelog/unreleased_20/12579.rst [new file with mode: 0644]
lib/sqlalchemy/engine/url.py
test/engine/test_parseconnect.py

diff --git a/doc/build/changelog/unreleased_20/12579.rst b/doc/build/changelog/unreleased_20/12579.rst
new file mode 100644 (file)
index 0000000..70c619d
--- /dev/null
@@ -0,0 +1,7 @@
+.. change::
+    :tags: bug, engine
+    :tickets: 12579
+
+    The error message that is emitted when a URL cannot be parsed no longer
+    includes the URL itself within the error message.
+
index f72940d4bd30313b9595451eed98bbbef833cc36..53f767fb92354b403a2fc5c86e2599cef97b29d1 100644 (file)
@@ -918,5 +918,5 @@ def _parse_url(name: str) -> URL:
 
     else:
         raise exc.ArgumentError(
-            "Could not parse SQLAlchemy URL from string '%s'" % name
+            "Could not parse SQLAlchemy URL from given URL string"
         )
index 254d9c00fe759b345e36b72d67ebbdf5555c2c42..00cdfc9bf52d59464ceb7f6731a0a194db10c04d 100644 (file)
@@ -804,6 +804,13 @@ class CreateEngineTest(fixtures.TestBase):
             module=mock_dbapi,
         )
 
+    def test_cant_parse_str(self):
+        with expect_raises_message(
+            exc.ArgumentError,
+            r"^Could not parse SQLAlchemy URL from given URL string$",
+        ):
+            create_engine("notarealurl")
+
     def test_urlattr(self):
         """test the url attribute on ``Engine``."""