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

libsql::Builder panics if given invalid remote db url #1261

Open
sveltespot opened this issue Mar 26, 2024 · 0 comments
Open

libsql::Builder panics if given invalid remote db url #1261

sveltespot opened this issue Mar 26, 2024 · 0 comments

Comments

@sveltespot
Copy link
Contributor

sveltespot commented Mar 26, 2024

Builder::new_remote_replica build panics if supplied with an invalid url.

When trying to build an embedded replica of a db with a malformed db url, the build() method just panics and crashes the thread. In my case, I was taking an un-sanitized db name from user as input (stupid of me, I know); create a new namespace in sqld and initialize the user db with that name and then create an embedded synced replica for that db. Surprisingly, sqld successfully creates a namespace even if the name would result in an invalid db_url (maybe I should create another issue for that) and when I try to create the embedded replica with that invalid url it just panics. For example, if the user input is db-name I create a sqld namespace for the same and the sqld instance is available at something like db-name.local which is then synced locally. This works fine as it should. But if the user input is something like db-name:3000, sqld creates a namespace for it even though the url to access this db would be db-name:3000.local which is invalid and embedded replica creation crashes.

The offending line seems to be this:

endpoint.as_str().try_into().unwrap(),

Not sure why there is a greedy unwrap here.

Expected: Gracefully error out with an appropriate error.

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

1 participant