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

Bad error message if URL or token is missing #19

Open
penberg opened this issue Nov 8, 2023 · 2 comments
Open

Bad error message if URL or token is missing #19

penberg opened this issue Nov 8, 2023 · 2 comments

Comments

@penberg
Copy link
Contributor

penberg commented Nov 8, 2023

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”).
@bbennett80
Copy link
Contributor

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.

@bbennett80
Copy link
Contributor

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.

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