`libsql::Builder` panics if given invalid remote db url
sveltespot opened this issue · comments
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:
libsql/libsql/src/local/database.rs
Line 94 in 966757a
Not sure why there is a greedy unwrap here.
Expected: Gracefully error out with an appropriate error.