Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"ValueError: Invalid IPv6 URL" when passing password with special characters #7

Open
BTheunissen opened this issue Nov 7, 2024 · 3 comments

Comments

@BTheunissen
Copy link

I am currently switching from using mypysql to the singlestore-python client in order to get more granular type information when inspecting tables programmatically. In this instance I am using the library with the SingleStore SQL Alchemy project.

It appears that if certain special characters specifically [ and ] are contained within the user password, then the URL parsing from urllib fails.

I've validated that if I URL encode the [ and ] values to %5B and %5D respectively, the issue still occurs even though if I test the url with urlsplit with Python on my system directly, then it can be successfully split.

I have a feeling that the call at base.py:L386 in the stack trace contains the issue, as we explicitly render the url back as a string which could undo any URL encoding that has been done upstream.

Would be grateful for a fix, thanks!

Stack Trace:

  File "/home/venv/lib/python3.11/site-packages/tap_mysql/client.py", line 57, in create_engine
    return sqlalchemy.create_engine(self.sqlalchemy_url, connect_args=connect_args, echo=False)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<string>", line 2, in create_engine
  File "/home/venv/lib/python3.11/site-packages/sqlalchemy/util/deprecations.py", line 375, in warned
    return fn(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^
  File "/home/venv/lib/python3.11/site-packages/sqlalchemy/engine/create.py", line 560, in create_engine
    (cargs, cparams) = dialect.create_connect_args(u)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/venv/lib/python3.11/site-packages/sqlalchemy_singlestoredb/base.py", line 386, in create_connect_args
    return [[], build_params(host=url.render_as_string(hide_password=False))]
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/venv/lib/python3.11/site-packages/singlestoredb/connection.py", line 150, in build_params
    urlp = _parse_url(host)
           ^^^^^^^^^^^^^^^^
  File "/home/venv/lib/python3.11/site-packages/singlestoredb/connection.py", line 267, in _parse_url
    parts = urlparse(url, scheme='singlestoredb', allow_fragments=True)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/cpython-3.11.6-macos-aarch64-none/lib/python3.11/urllib/parse.py", line 395, in urlparse
    splitresult = urlsplit(url, scheme, allow_fragments)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/python/cpython-3.11.6-macos-aarch64-none/lib/python3.11/urllib/parse.py", line 497, in urlsplit
    raise ValueError("Invalid IPv6 URL")
ValueError: Invalid IPv6 URL
@kesmit13
Copy link
Collaborator

kesmit13 commented Nov 8, 2024

This could be something in the SingleStore SQLAlchemy dialect, or maybe the SingleStoreDB client itself. What version of the client are you running?

@BTheunissen
Copy link
Author

I am running the latest release of SingleStore SQLAlchemy 1.1.1, and SingleStore Client 1.7.2.

@kesmit13
Copy link
Collaborator

This is actually an issue in the SingleStore client itself. There is a fix in the main branch. If you can try that out and let me know if it fixes the problem, I can do a release. singlestore-labs/singlestoredb-python@074cb03

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants