Skip to content
This repository has been archived by the owner on Oct 17, 2020. It is now read-only.

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

Open
rohithbalaji123 opened this issue May 7, 2020 · 3 comments
Labels
bug Something isn't working Go Issue requires to write code using Go language p1 Medium priority
Projects

Comments

@rohithbalaji123
Copy link
Member

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 rohithbalaji123 added bug Something isn't working Go Issue requires to write code using Go language p1 Medium priority labels May 7, 2020
@Coteh
Copy link
Collaborator

Coteh commented May 8, 2020

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
Copy link
Collaborator

Coteh commented May 8, 2020

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

@magicoder10
Copy link
Member

@Coteh Need to think about this.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working Go Issue requires to write code using Go language p1 Medium priority
Projects
Short 1.0
  
Awaiting triage
Development

No branches or pull requests

3 participants