short icon indicating copy to clipboard operation
short copied to clipboard

[BUG] Creating short links with empty alias throws unkown error at times

Open rohithbalaji123 opened this issue 5 years ago • 3 comments

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

  1. Go to https://staging-short.com and paste a random link in the Long Link text box.
  2. Without filling any values for alias, try creating the link for 3 to 4 times.
  3. Look for the pattern the key generation service uses to create new alias (usually increments the last character in the string by 1).
  4. Now, generate the short link with the next expected alias by manually typing it in the alias input box.
  5. Once generated, clear the alias input box and try creating short link again.
  6. 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 image

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.

rohithbalaji123 avatar May 07 '20 04:05 rohithbalaji123

I just tried reproducing it on my end, and I get Alias already exists as expected: image

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)

Coteh avatar May 08 '20 19:05 Coteh

Also, should THRESHOLD be an environment variable with a sensible default value like 3?

Coteh avatar May 08 '20 19:05 Coteh

@Coteh Need to think about this.

magicoder10 avatar May 08 '20 20:05 magicoder10