[BUG] Creating short links with empty alias throws unkown error at times
Describe the bug When given empty alias, the application shows unknown error when the key generation service tries to allot the alias which already exists in the user created alias list.
To Reproduce
- Go to https://staging-short.com and paste a random link in the Long Link text box.
- Without filling any values for alias, try creating the link for 3 to 4 times.
- Look for the pattern the key generation service uses to create new alias (usually increments the last character in the string by 1).
- Now, generate the short link with the next expected alias by manually typing it in the alias input box.
- Once generated, clear the alias input box and try creating short link again.
- You can see the error attached in the screenshot.
Expected behavior If the alias given by key generation service already exists in the database, the app should keep fetching next key until it finds a unique alias. Preferably, this could keep fetching for a THRESHOLD number of times and if it still couldn't find a unique alias, it could error out and notify the administrator about the incident.
Screenshots

Additional context Even with the above issue, the expected error should be known "Alias already exists". We need to figure out what is causing unknown error.
I just tried reproducing it on my end, and I get Alias already exists as expected:

I'm interested in working on the other part of the issue though. It seems like we can add a check for IsAliasExist within createURLWithAutoAlias and cycle through that THRESHOLD number of times or until an available alias is selected. Do you think we'll run into issues with concurrency? (if multiple users are making requests to create alias to backend)
Also, should THRESHOLD be an environment variable with a sensible default value like 3?
@Coteh Need to think about this.