3093: prevent adding a duplicated repo name on reviewboard server

nan****@gmai***** (Google Code) (Is this you? Claim this profile.)
david
david
Jan. 18, 2014
What version are you running?
1.7.6


What's the URL of the page containing the problem?
/admin/db/scmtools/repository/add

What steps will reproduce the problem?
1. create a first repo with name "repository" (for example)
2. create a second one with same name "repository"
could be reproduced using rest api too

What is the expected output? 
prevent form being validated because a repository and notify submitter a repo with same name already exists

What do you see instead?
a 2nd repo with same name has been created, and review request on this repo will fail with error

MultipleObjectsReturned: get() returned more than one Repository -- it returned 2! Lookup parameters were {}

What operating system are you using? What browser?
any

In our case it happens often because we have already several repo defined (196) and people do not check everytime a repo name already exists on second page of repo list :-(
chipx86
#1 chipx86
What database are you using? We have constraints in place to prevent duplicate names, but it does depend on the database to enforce it.
  • +NeedInfo
#2 nan****@gmai***** (Google Code) (Is this you? Claim this profile.)
our server is configured to use MySQL database. 

Ihave not  checked yet if there is a uniq for repo name field 
#3 nan****@gmai***** (Google Code) (Is this you? Claim this profile.)
I've just checked, There is no unique=True for charfield name from repository class whereas there is one for tool.name 

 https://github.com/reviewboard/reviewboard/blob/master/reviewboard/scmtools/models.py

Will this kind of change (adding unique) be supported by a django-evolution script?
david
#4 david
We do have a unique_together constraint with repository name and local site, but apparently those aren't enforced when one of the pair is null. I think we probably need to handle this in the admin form instead.

See bug 3066 for a similar issue.
chipx86
#5 chipx86
We use unique_together= in the Meta definition for the model.

However, django-evolution does not appear to support this, so if your installation is from pre-1.6 days, that's probably it.
david
#6 david
  • -NeedInfo
    +Started
  • +Component-SCMTools
  • +david
david
#7 david
Fixed in release-1.7.x (3edb765). This will ship with 1.7.22
  • -Started
    +Fixed
#8 sorin.*******@gmai***** (Google Code) (Is this you? Claim this profile.)
It seems that this problem wasn't really fixed as we can see it very often on 2.0.15 - see https://gist.githubusercontent.com/ssbarnea/53dba96497529e6b7d49/raw/f38c738768fd360104c5b175fa01b442a1c9cfc5/gistfile1.txt
david
#9 david
The fix only prevents getting in to this situation in the first place. If you already have duplicate entries in your database, then you'll need to go in and fix them up by hand.