inserting row with duplicate primary key returns 500 instead of useful error

RESOLVED FIXED

Status

P3
normal
RESOLVED FIXED
a year ago
a year ago

People

(Reporter: bhearsum, Assigned: daniel.kitui)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

(Whiteboard: [lang=python][ready], URL)

Eg: TransactionError: ('(IntegrityError) (1062, "Duplicate entry \'SystemAddons-shield-recipe-client-1.0.0\' for key \'PRIMARY\'")',)
  File "flask/app.py", line 1817, in wsgi_app
    response = self.full_dispatch_request()
  File "flask/app.py", line 1477, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "flask/app.py", line 1381, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "flask/app.py", line 1475, in full_dispatch_request
    rv = self.dispatch_request()
  File "flask/app.py", line 1461, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "flask/views.py", line 84, in view
    return self.dispatch_request(*args, **kwargs)
  File "flask/views.py", line 149, in dispatch_request
    return meth(*args, **kwargs)
  File "auslib/web/admin/views/base.py", line 26, in decorated
    return f(*args, **kwargs)
  File "auslib/web/admin/views/base.py", line 70, in post
    return self._post(*args, transaction=trans, **kwargs)
  File "auslib/web/admin/views/base.py", line 70, in post
    return self._post(*args, transaction=trans, **kwargs)
  File "auslib/web/admin/views/base.py", line 18, in decorated
    return f(*args, changed_by=username, **kwargs)
  File "auslib/web/admin/views/releases.py", line 477, in _post
    data=blob)
  File "auslib/db.py", line 1915, in insert
    ret = super(Releases, self).insert(changed_by=changed_by, transaction=transaction, dryrun=dryrun, **columns)
  File "auslib/db.py", line 413, in insert
    return self._prepareInsert(transaction, changed_by, **columns)
  File "auslib/db.py", line 383, in _prepareInsert
    ret = trans.execute(query)
  File "auslib/db.py", line 199, in execute
    return self.conn.execute(statement)
  File "sqlalchemy/engine/base.py", line 1358, in execute
    params)
  File "sqlalchemy/engine/base.py", line 1491, in _execute_clauseelement
    compiled_sql, distilled_params
  File "sqlalchemy/engine/base.py", line 1599, in _execute_context
    context)
  File "sqlalchemy/engine/base.py", line 1592, in _execute_context
    context)
  File "sqlalchemy/engine/default.py", line 325, in do_execute
    cursor.execute(statement, parameters)
  File "MySQLdb/cursors.py", line 174, in execute
    self.errorhandler(self, exc, value)
  File "MySQLdb/connections.py", line 36, in defaulterrorhandler
    raise errorclass, errorvalue

This should probably either be caught or avoided completely at the db level, and a ValueError raised instead.
(Reporter)

Updated

a year ago
Priority: -- → P3
(Reporter)

Updated

a year ago
Mentor: bhearsum
(Reporter)

Updated

a year ago
Mentor: bhearsum

Comment 1

a year ago
I would like to work on this.
(In reply to Mercy Muchai from comment #1)
> I would like to work on this.

It's all yours! Please be sure to add test(s) for it.
Assignee: nobody → mercy.muchai

Updated

a year ago
Assignee: mercy.muchai → alvin.mutisya

Updated

a year ago
Assignee: alvin.mutisya → daniel.kitui
(Assignee)

Comment 3

a year ago
I would like to replicate this bug in my local environment as starting point. How can I go about this?
Flags: needinfo?(bhearsum)
Hmm, it looks like this got fixed as a side effect of something else at some point. I can't reproduce it anymore...

Sorry!
Status: NEW → RESOLVED
Last Resolved: a year ago
Flags: needinfo?(bhearsum)
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.