Description of problem: Attempting to create a new account with an alternate username when the account already exists may result in a traceback. Steps to Reproduce: 1. Create an account 2. Log out 3. Attempt to create another account with a different username, but keep all other information the same This was uncovered by Scott Glaser when he forgot about his existing account and attempted to create a new one. This should result in a friendly error message that tells the user what is happening. His traceback from http://rafb.net/paste/results/lnSAhS74.html : INSERT INTO person (username, human_name, email, gpg_keyid, ssh_key, password, comments, postal_address, affiliation, telephone, facsimile, approval_status) VALUES ('sglaser', 'Scott Glaser', 'sonar_guy', '599000BD', 'ssh-dss AAAAB3NzaC1kc3MAAAEBALzSquClMU8PUha+1eNjBbDHBVNH7XdStgzOpol2gw0Mq1mKwIchI+mUvqAHQ/Isv2W7lngFtxWmgaqCAH4qSUIJLrVvWOGP6DE7rcrx7cL1gSNNsS+/brwzO2eLDCXWFJ1uE2BFczeOwER3ZEdSRGe9zN0w1IWD9t+XWz8Bj8lLVzyJgYvvnqLapO85kKs011w9AaRqiMeVaTWd+fMo0mQ2E2gDKuNAfTHuB8VVpbM0Vj5JsmYmXPRknZR4WIoyQD0TqJi7WZCTpzZD0TyUiaUgB5Bov5CJ3G/ISvI4UBc4Y8M2x3auPT+c4OSbTiwQcKiy2GqQWzqVsEoPZDehHnMAAAAVAJoO5I/UbtNEmfQSHWryvF0GcQd9AAABAQCJdSeP0/XyJnvDV5oNcsI61wmmwhFbznnIIlzX0LH6bmGhmX0S0/FTUHKHGV5We11P0xjxLhZsiAa2l4DSFYxYyNZQ3CQRikq8WCj/QWoRGjHI3M8UeVyzqyk4LzTMg3Lz3u2ysfxpvS2q5Yi8Rgy3328FaAWS/c4sRmDxnSgrzE+NMjx10JJBxC36+3gOmJEplYm27Azir60Re1YO0FTrCZYXPCezF84Ba68OtASGgYVlHypz/HIbpkyGcy1Y4IKzdqYGObyBSxcbAFE5yoqw8WcGJLFshuV63dilRn8wGHJaNKH4RuzLnOdZHUg/sKBXZO1FCcYTpLsxR1+OD3NaAAABAQCi1dj3C3pXna0GB1woXRGgdWklBAZ4Ph7mnlSazufU3tSpOZ13L3PjrsLVmRrMRLeM9lLksMz1p3jPtPaDpf+B/QPlMqzsl3jjJFbDZxxGiM6/P0Xzjy/HA7QEMHNqbUnkv9k6GTHHIGvZUxgUKJQnbrUDqTFtrnGdAYWUeaLeEY4IFbDct7B5fz9JQxfB9YMQKR+hvIgOkAxT7ky/s5mUBjQ8Lxy8WRReM0Xfw9j3KwniE9Yjj5egJnWg8uJRXngbGOXv7x5TAt95Dq36BBlxUKSh9JenTNGyHnm1QrfTTYyR4C2/B1/55N1cqy+K7nAeINDnGdCtRYFuWfMEJyIh sglaser.com', '726902', '', '1001 Birch Lake Crescent APT # 202', '', '757-428-0817', '', 'approved') Traceback (most recent call last): File "/var/www/html/admin/accounts/userbox.cgi", line 180, in do_action field_values) File "/var/www/html/admin/accounts/pgdb.py", line 184, in execute self.executemany(operation, (params,)) File "/var/www/html/admin/accounts/pgdb.py", line 199, in executemany rows = self.__source.execute(sql) _pg.error: ERROR: duplicate key violates unique constraint "person_email_key" SELECT * FROM person WHERE username = 'sglaser' --> --> Your full name: _pg.error Python 2.2.3: /usr/bin/python2 Tue Jan 3 22:54:39 2006 A problem occurred in a Python script. Here is the sequence of function calls leading up to the error, in the order they occurred. /var/www/html/admin/accounts/userbox.cgi 298 if action_error: 299 print action_error 300 do_form(form, fields, action, got_submit) 301 if username and action=='edit': 302 website.handle_group_mods(dbh, form, 'userbox.cgi', username, do_form = <function do_form>, form = FieldStorage(None, None, [FieldStorage('human_na... ''), FieldStorage('_createme', None, 'Submit')]), fields = ({'can_edit': 0, 'check': <function check_notempty>, 'desc': 'Your full name', 'maxlen': 50, 'name': 'human_name'}, {'can_edit': 0, 'check': <function check_username>, 'desc': 'Username', 'maxlen': 8, 'name': 'username'}, {'check': <function check_email>, 'desc': 'E-mail address', 'maxlen': 80, 'name': 'email', 'notes': 'Your E-mail address must be the one you use for your GPG key and bugzilla account'}, {'check': <function check_notempty>, 'desc': 'Postal Address', 'maxlen': 1024, 'name': 'postal_address'}, {'check': <function check_notempty>, 'desc': 'Telephone', 'maxlen': 128, 'name': 'telephone'}, {'desc': 'Facsimile', 'maxlen': 128, 'name': 'facsimile'}, {'desc': 'Affiliation', 'maxlen': 64, 'name': 'affiliation'}, {'check': <function check_gpg_keyid>, 'desc': '<a href="http://fedoraproject.org/wiki/DocsProject/UsingGpg/CreatingKeys">GPG KeyID</a>', 'maxlen': 16, 'name': 'gpg_keyid'}, {'check': <function check_sshkey>, 'desc': 'SSHv2 Public Key (attach your ~/.ssh/id_dsa.pub file here)', 'maxlen': 2048, 'name': 'ssh_key', 'strip': 1, 'type': 'file'}, {'check': <function check_notempty_onnew>, 'desc': 'Password', 'edit_reuse': 0, 'maxlen': 20, 'name': 'password', 'type': 'password'}, {'check': <function check_double_password>, 'db_field': 0, 'desc': 'Password (again)', 'edit_reuse': 0, 'maxlen': 20, 'name': 'password_check', 'type': 'password'}, {'desc': 'IRC nickname', 'maxlen': 32, 'name': 'ircnick'}, {'desc': 'Comments', 'maxlen': 1024, 'name': 'comments', 'skip_empty': 0}), action = 'create', got_submit = 1 /var/www/html/admin/accounts/userbox.cgi in do_form(form=FieldStorage(None, None, [FieldStorage('human_na... ''), FieldStorage('_createme', None, 'Submit')]), fields=({'can_edit': 0, 'check': <function check_notempty>, 'desc': 'Your full name', 'maxlen': 50, 'name': 'human_name'}, {'can_edit': 0, 'check': <function check_username>, 'desc': 'Username', 'maxlen': 8, 'name': 'username'}, {'check': <function check_email>, 'desc': 'E-mail address', 'maxlen': 80, 'name': 'email', 'notes': 'Your E-mail address must be the one you use for your GPG key and bugzilla account'}, {'check': <function check_notempty>, 'desc': 'Postal Address', 'maxlen': 1024, 'name': 'postal_address'}, {'check': <function check_notempty>, 'desc': 'Telephone', 'maxlen': 128, 'name': 'telephone'}, {'desc': 'Facsimile', 'maxlen': 128, 'name': 'facsimile'}, {'desc': 'Affiliation', 'maxlen': 64, 'name': 'affiliation'}, {'check': <function check_gpg_keyid>, 'desc': '<a href="http://fedoraproject.org/wiki/DocsProject/UsingGpg/CreatingKeys">GPG KeyID</a>', 'maxlen': 16, 'name': 'gpg_keyid'}, {'check': <function check_sshkey>, 'desc': 'SSHv2 Public Key (attach your ~/.ssh/id_dsa.pub file here)', 'maxlen': 2048, 'name': 'ssh_key', 'strip': 1, 'type': 'file'}, {'check': <function check_notempty_onnew>, 'desc': 'Password', 'edit_reuse': 0, 'maxlen': 20, 'name': 'password', 'type': 'password'}, {'check': <function check_double_password>, 'db_field': 0, 'desc': 'Password (again)', 'edit_reuse': 0, 'maxlen': 20, 'name': 'password_check', 'type': 'password'}, {'desc': 'IRC nickname', 'maxlen': 32, 'name': 'ircnick'}, {'desc': 'Comments', 'maxlen': 1024, 'name': 'comments', 'skip_empty': 0}), action='create', got_submit=1) 129 cfunc = I.get('check') 130 if cfunc: 131 objection = cfunc(form, I, curval, action) 132 print "<tr><td align=left valign=top>" 133 the_desc = I['desc'] objection = None, cfunc = <function check_username>, form = FieldStorage(None, None, [FieldStorage('human_na... ''), FieldStorage('_createme', None, 'Submit')]), I = {'can_edit': 0, 'check': <function check_username>, 'desc': 'Username', 'maxlen': 8, 'name': 'username'}, curval = 'sglaser', action = 'create' /var/www/html/admin/accounts/userbox.cgi in check_username(form=FieldStorage(None, None, [FieldStorage('human_na... ''), FieldStorage('_createme', None, 'Submit')]), field_info={'can_edit': 0, 'check': <function check_username>, 'desc': 'Username', 'maxlen': 8, 'name': 'username'}, value='sglaser', action='create') 66 return "Invalid value" 67 dbc = dbh.cursor() 68 dbc.execute("SELECT * FROM person WHERE username = %s", (value,)) 69 rc = dbc.rowcount 70 dbh.rollback() dbc = <website.PostgresDBCursor instance>, dbc.execute = <bound method pgdbCursor.execute of <pgdb.pgdbCursor instance>>, value = 'sglaser' /var/www/html/admin/accounts/pgdb.py in execute(self=<pgdb.pgdbCursor instance>, operation='SELECT * FROM person WHERE username = %s', params=('sglaser',)) 182 183 def execute(self, operation, params = None): 184 self.executemany(operation, (params,)) 185 186 def executemany(self, operation, param_seq): self = <pgdb.pgdbCursor instance>, self.executemany = <bound method pgdbCursor.executemany of <pgdb.pgdbCursor instance>>, operation = 'SELECT * FROM person WHERE username = %s', params = ('sglaser',) /var/www/html/admin/accounts/pgdb.py in executemany(self=<pgdb.pgdbCursor instance>, operation='SELECT * FROM person WHERE username = %s', param_seq=(('sglaser',),)) 197 else: 198 sql = operation 199 rows = self.__source.execute(sql) 200 if rows != None: # true is __source is NOT a DQL 201 totrows = totrows + rows rows undefined, self = <pgdb.pgdbCursor instance>, self.__source undefined, sql = "SELECT * FROM person WHERE username = 'sglaser'" _pg.error: ERROR: current transaction is aborted, commands ignored until end of transaction block
This problem should no longer exist in FAS2.