magfest-archive / guests

Magfest band management plugin for ubersystem
GNU Affero General Public License v3.0
1 stars 1 forks source link

error occurs if you try and save a band agreement that has already been saved #32

Closed binary1230 closed 8 years ago

binary1230 commented 8 years ago

to repro: 1) go through the steps to get a band created 2) go through the /agreement page, hit Save 3) go back to the agreement page, hit Save again

expected: agreement page saves any new data entered

actual:

500 Internal Server Error

The server encountered an unexpected condition which prevented it from fulfilling the request.

Traceback (most recent call last):
  File "/home/vagrant/uber/sideboard/plugins/uber/uber/decorators.py", line 194, in with_session
    retval = func(*args, session=session, **kwargs)
  File "/home/vagrant/uber/sideboard/plugins/uber/uber/decorators.py", line 278, in with_restrictions
    return func(*args, **kwargs)
  File "/home/vagrant/uber/sideboard/plugins/uber/uber/decorators.py", line 240, in with_rendering
    result = func(*args, **kwargs)
  File "/home/vagrant/uber/sideboard/plugins/bands/bands/site_sections/bands.py", line 27, in agreement
    raise HTTPRedirect('index?id={}&message={}', band.id, 'Your band information has been uploaded')
uber.utils.HTTPRedirect: (['http://localhost/uber/bands/index?id=3a7f033d-d88a-4854-9bbb-4977505c0578&message=Your%20band%20information%20has%20been%20uploaded'], 302)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/vagrant/uber/sideboard/env/lib/python3.4/site-packages/sqlalchemy/engine/base.py", line 1139, in _execute_context
    context)
  File "/home/vagrant/uber/sideboard/env/lib/python3.4/site-packages/sqlalchemy/engine/default.py", line 442, in do_execute
    cursor.execute(statement, parameters)
psycopg2.IntegrityError: duplicate key value violates unique constraint "band_info_band_id_key"
DETAIL:  Key (band_id)=(3a7f033d-d88a-4854-9bbb-4977505c0578) already exists.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/vagrant/uber/sideboard/env/lib/python3.4/site-packages/cherrypy/_cprequest.py", line 670, in respond
    response.body = self.handler()
  File "/home/vagrant/uber/sideboard/env/lib/python3.4/site-packages/cherrypy/lib/encoding.py", line 217, in __call__
    self.body = self.oldhandler(*args, **kwargs)
  File "/home/vagrant/uber/sideboard/env/lib/python3.4/site-packages/cherrypy/_cpdispatch.py", line 61, in __call__
    return self.callable(*self.args, **self.kwargs)
  File "/home/vagrant/uber/sideboard/plugins/uber/uber/decorators.py", line 179, in with_timing
    return func(*args, **kwargs)
  File "/home/vagrant/uber/sideboard/plugins/uber/uber/decorators.py", line 170, in with_caching
    return func(*args, **kwargs)
  File "/home/vagrant/uber/sideboard/plugins/uber/uber/decorators.py", line 198, in with_session
    session.commit()
  File "/home/vagrant/uber/sideboard/env/lib/python3.4/site-packages/sqlalchemy/orm/session.py", line 790, in commit
    self.transaction.commit()
  File "/home/vagrant/uber/sideboard/env/lib/python3.4/site-packages/sqlalchemy/orm/session.py", line 392, in commit
    self._prepare_impl()
  File "/home/vagrant/uber/sideboard/env/lib/python3.4/site-packages/sqlalchemy/orm/session.py", line 372, in _prepare_impl
    self.session.flush()
  File "/home/vagrant/uber/sideboard/env/lib/python3.4/site-packages/sqlalchemy/orm/session.py", line 2004, in flush
    self._flush(objects)
  File "/home/vagrant/uber/sideboard/env/lib/python3.4/site-packages/sqlalchemy/orm/session.py", line 2122, in _flush
    transaction.rollback(_capture_exception=True)
  File "/home/vagrant/uber/sideboard/env/lib/python3.4/site-packages/sqlalchemy/util/langhelpers.py", line 60, in __exit__
    compat.reraise(exc_type, exc_value, exc_tb)
  File "/home/vagrant/uber/sideboard/env/lib/python3.4/site-packages/sqlalchemy/util/compat.py", line 182, in reraise
    raise value
  File "/home/vagrant/uber/sideboard/env/lib/python3.4/site-packages/sqlalchemy/orm/session.py", line 2086, in _flush
    flush_context.execute()
  File "/home/vagrant/uber/sideboard/env/lib/python3.4/site-packages/sqlalchemy/orm/unitofwork.py", line 373, in execute
    rec.execute(self)
  File "/home/vagrant/uber/sideboard/env/lib/python3.4/site-packages/sqlalchemy/orm/unitofwork.py", line 532, in execute
    uow
  File "/home/vagrant/uber/sideboard/env/lib/python3.4/site-packages/sqlalchemy/orm/persistence.py", line 174, in save_obj
    mapper, table, insert)
  File "/home/vagrant/uber/sideboard/env/lib/python3.4/site-packages/sqlalchemy/orm/persistence.py", line 729, in _emit_insert_statements
    execute(statement, multiparams)
  File "/home/vagrant/uber/sideboard/env/lib/python3.4/site-packages/sqlalchemy/engine/base.py", line 914, in execute
    return meth(self, multiparams, params)
  File "/home/vagrant/uber/sideboard/env/lib/python3.4/site-packages/sqlalchemy/sql/elements.py", line 323, in _execute_on_connection
    return connection._execute_clauseelement(self, multiparams, params)
  File "/home/vagrant/uber/sideboard/env/lib/python3.4/site-packages/sqlalchemy/engine/base.py", line 1010, in _execute_clauseelement
    compiled_sql, distilled_params
  File "/home/vagrant/uber/sideboard/env/lib/python3.4/site-packages/sqlalchemy/engine/base.py", line 1146, in _execute_context
    context)
  File "/home/vagrant/uber/sideboard/env/lib/python3.4/site-packages/sqlalchemy/engine/base.py", line 1332, in _handle_dbapi_exception
    exc_info
  File "/home/vagrant/uber/sideboard/env/lib/python3.4/site-packages/sqlalchemy/util/compat.py", line 188, in raise_from_cause
    reraise(type(exception), exception, tb=exc_tb, cause=exc_value)
  File "/home/vagrant/uber/sideboard/env/lib/python3.4/site-packages/sqlalchemy/util/compat.py", line 181, in reraise
    raise value.with_traceback(tb)
  File "/home/vagrant/uber/sideboard/env/lib/python3.4/site-packages/sqlalchemy/engine/base.py", line 1139, in _execute_context
    context)
  File "/home/vagrant/uber/sideboard/env/lib/python3.4/site-packages/sqlalchemy/engine/default.py", line 442, in do_execute
    cursor.execute(statement, parameters)
sqlalchemy.exc.IntegrityError: (psycopg2.IntegrityError) duplicate key value violates unique constraint "band_info_band_id_key"
DETAIL:  Key (band_id)=(3a7f033d-d88a-4854-9bbb-4977505c0578) already exists.
 [SQL: 'INSERT INTO band_info (id, band_id, poc_phone, performer_count, bringing_vehicle, vehicle_info, arrival_time) VALUES (%(id)s, %(band_id)s, %(poc_phone)s, %(performer_count)s, %(bringing_vehicle)s, %(vehicle_info)s, %(arrival_time)s)'] [parameters: {'vehicle_info': 'monster truck', 'poc_phone': '1231231234', 'bringing_vehicle': True, 'arrival_time': '10am tursday', 'performer_count': 3, 'id': UUID('14907bbf-be36-4407-8cc9-e72abb905b0b'), 'band_id': UUID('3a7f033d-d88a-4854-9bbb-4977505c0578')}]
kitsuta commented 8 years ago

@EliAndrewC I thought you said we didn't need session.merge() but this error seems to indicate that we do? It's trying to insert a new object with the same id as the old object.

binary1230 commented 8 years ago

seeing this coming up again in devbots_errors currently

binary1230 commented 8 years ago

currently still happening, it's public-facing for some of our bands on maglabs. once we get done launch we should spend some time tracking this down

kitsuta commented 8 years ago

@EliAndrewC Pinging again on this, do you know what's up?