libsql-client-py
libsql-client-py copied to clipboard
Bad error message if URL or token is missing
An user reports the following error when accidentally removing load_dotenv() call causing to miss URL and access token:
LibsqlError(f”Unsupported URL scheme {config.scheme!r}”, “URL_SCHEME_NOT_SUPPORTED”).
Hello @penberg. First, thank you for your help on Discord, very much appreciated. Second, here is the message error message: LibsqlError: URL_SCHEME_NOT_SUPPORTED: Unsupported URL scheme b''.
I'll look into client.py.
How do you feel about adding another conditional (elif not url) to libsql_client/create_client.py?
def create_client(url: str, *, auth_token: Optional[str] = None) -> Client:
config = _expand_config(url, auth_token=auth_token)
if config.scheme == "libsql":
config = config._replace(scheme="wss")
if config.scheme == "file":
return _create_sqlite3_client(config)
elif config.scheme in ("ws", "wss"):
return _create_hrana_client(config)
elif config.scheme in ("http", "https"):
return _create_http_client(config)
elif not url:
raise LibsqlError(f"Database URL is {url}.", "URL_UNDEFINED")
else:
raise LibsqlError(
f"Unsupported URL scheme {config.scheme!r}", "URL_SCHEME_NOT_SUPPORTED"
)
It appears that an error for no JWT is handled well from libsql_client/hrana/conn.py inside def _receive.