harvard-lil / h2o

H2O is a web app for creating and reading open educational resources, primarily in the legal field
https://opencasebook.org
GNU Affero General Public License v3.0
37 stars 30 forks source link

Inviting the same collaborator email twice results in a server error #1821

Closed sentry-io[bot] closed 1 year ago

sentry-io[bot] commented 1 year ago

It should be possible to catch this error rather than let it 500.

Sentry Issue: H2O-35

UniqueViolation: duplicate key value violates unique constraint "main_tempcollaborator_user_id_casebook_id_392572a0_uniq"
DETAIL:  Key (user_id, casebook_id)=(128390, 6361) already exists.

  File "django/db/backends/utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)

IntegrityError: duplicate key value violates unique constraint "main_tempcollaborator_user_id_casebook_id_392572a0_uniq"
DETAIL:  Key (user_id, casebook_id)=(128390, 6361) already exists.

(17 additional frame(s) were not displayed)
...
  File "django/db/backends/utils.py", line 66, in execute
    return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
  File "django/db/backends/utils.py", line 75, in _execute_with_wrappers
    return executor(sql, params, many, context)
  File "django/db/backends/utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
  File "django/db/utils.py", line 90, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "django/db/backends/utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)