Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: 500 error for /report_submission/accessandsubmission: Duplicate key violation #4638

Open
phildominguez-gsa opened this issue Jan 16, 2025 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@phildominguez-gsa
Copy link
Contributor

Example: https://onenr.io/0MRN8yva7Qn

{
"exc_info": "Traceback (most recent call last):\n File "/home/vcap/deps/1/python/lib/python3.12/site-packages/django/db/backends/utils.py", line 105, in _execute\n return self.cursor.execute(sql, params)\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File "/home/vcap/deps/1/python/lib/python3.12/site-packages/newrelic/hooks/database_psycopg2.py", line 54, in execute\n return super(CursorWrapper, self).execute(sql, parameters, *args, **kwargs)\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File "/home/vcap/deps/1/python/lib/python3.12/site-packages/newrelic/hooks/database_dbapi2.py", line 42, in execute\n return self.wrapped.execute(sql, parameters, *args, **kwargs)\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\npsycopg2.errors.UniqueViolation: duplicate key value violates unique constraint "audit_singleauditchecklist_report_id_key"\nDETAIL: Key (report_id)=(2023-06-GSAFAC-0000350231) already exists.\n\n\nThe above exception was the direct cause of the following exception:\n\nTraceback (most recent call last):\n File "/home/vcap/deps/1/python/lib/python3.12/site-packages/django/core/handlers/exception.py", line 55, in inner\n response = get_response(request)\n ^^^^^^^^^^^^^^^^^^^^^\n File "/home/vcap/deps/1/python/lib/python3.12/site-packages/django/core/handlers/base.py", line 197, in _get_response\n response = wrapped_callback(request, *callback_args, **callback_kwargs)\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File "/home/vcap/deps/1/python/lib/python3.12/site-packages/newrelic/hooks/framework_django.py", line 527, in wrapper\n return wrapped(*args, **kwargs)\n ^^^^^^^^^^^^^^^^^^^^^^^^\n File "/home/vcap/deps/1/python/lib/python3.12/site-packages/django/views/generic/base.py", line 104, in view\n return self.dispatch(request, *args, **kwargs)\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File "/home/vcap/deps/1/python/lib/python3.12/site-packages/django/contrib/auth/mixins.py", line 73, in dispatch\n return super().dispatch(request, *args, **kwargs)\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File "/home/vcap/deps/1/python/lib/python3.12/site-packages/newrelic/hooks/framework_django.py", line 900, in wrapper\n return wrapped(*args, **kwargs)\n ^^^^^^^^^^^^^^^^^^^^^^^^\n File "/home/vcap/deps/1/python/lib/python3.12/site-packages/django/views/generic/base.py", line 143, in dispatch\n return handler(request, *args, **kwargs)\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File "/home/vcap/app/report_submission/views.py", line 121, in post\n result = api.views.access_and_submission_check(request.user, request.POST)\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File "/home/vcap/app/api/views.py", line 114, in access_and_submission_check\n sac = SingleAuditChecklist.objects.create(\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File "/home/vcap/app/audit/models/models.py", line 106, in create\n result = super().create(**updated)\n ^^^^^^^^^^^^^^^^^^^^^^^^^\n File "/home/vcap/deps/1/python/lib/python3.12/site-packages/django/db/models/manager.py", line 87, in manager_method\n return getattr(self.get_queryset(), name)(*args, **kwargs)\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File "/home/vcap/deps/1/python/lib/python3.12/site-packages/django/db/models/query.py", line 679, in create\n obj.save(force_insert=True, using=self.db)\n File "/home/vcap/app/audit/models/models.py", line 216, in save\n return super().save()\n ^^^^^^^^^^^^^^\n File "/home/vcap/deps/1/python/lib/python3.12/site-packages/django/db/models/base.py", line 891, in save\n self.save_base(\n File "/home/vcap/deps/1/python/lib/python3.12/site-packages/django/db/models/base.py", line 997, in save_base\n updated = self._save_table(\n ^^^^^^^^^^^^^^^^^\n File "/home/vcap/deps/1/python/lib/python3.12/site-packages/django/db/models/base.py", line 1160, in _save_table\n results = self._do_insert(\n ^^^^^^^^^^^^^^^^\n File "/home/vcap/deps/1/python/lib/python3.12/site-packages/django/db/models/base.py", line 1201, in _do_insert\n return manager._insert(\n ^^^^^^^^^^^^^^^^\n File "/home/vcap/deps/1/python/lib/python3.12/site-packages/django/db/models/manager.py", line 87, in manager_method\n return getattr(self.get_queryset(), name)(*args, **kwargs)\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File "/home/vcap/deps/1/python/lib/python3.12/site-packages/django/db/models/query.py", line 1847, in _insert\n return query.get_compiler(using=using).execute_sql(returning_fields)\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File "/home/vcap/deps/1/python/lib/python3.12/site-packages/django/db/models/sql/compiler.py", line 1836, in execute_sql\n cursor.execute(sql, params)\n File "/home/vcap/deps/1/python/lib/python3.12/site-packages/django/db/backends/utils.py", line 79, in execute\n return self._execute_with_wrappers(\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File "/home/vcap/deps/1/python/lib/python3.12/site-packages/django/db/backends/utils.py", line 92, in _execute_with_wrappers\n return executor(sql, params, many, context)\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File "/home/vcap/deps/1/python/lib/python3.12/site-packages/django/db/backends/utils.py", line 100, in _execute\n with self.db.wrap_database_errors:\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File "/home/vcap/deps/1/python/lib/python3.12/site-packages/django/db/utils.py", line 91, in exit\n raise dj_exc_value.with_traceback(traceback) from exc_value\n File "/home/vcap/deps/1/python/lib/python3.12/site-packages/django/db/backends/utils.py", line 105, in _execute\n return self.cursor.execute(sql, params)\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File "/home/vcap/deps/1/python/lib/python3.12/site-packages/newrelic/hooks/database_psycopg2.py", line 54, in execute\n return super(CursorWrapper, self).execute(sql, parameters, *args, **kwargs)\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File "/home/vcap/deps/1/python/lib/python3.12/site-packages/newrelic/hooks/database_dbapi2.py", line 42, in execute\n return self.wrapped.execute(sql, parameters, *args, **kwargs)\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\ndjango.db.utils.IntegrityError: duplicate key value violates unique constraint "audit_singleauditchecklist_report_id_key"\nDETAIL: Key (report_id)=(2023-06-GSAFAC-0000350231) already exists.\n",
"host": "gsa-tts-oros-fac.production.gsa-fac",
"ident": "5dac166f-2fb0-4e72-8d4d-4359191bf284",
"message": "Internal Server Error: /report_submission/accessandsubmission/",
"newrelic.source": "api.logs",
"plugin.source": "BARE-METAL",
"plugin.type": "fluent-bit",
"plugin.version": "2.0.0",
"pri": "11",
"ptype": "APP/PROC/WEB/0",
"raw_message": "<11>1 2025-01-13T22:04:55.465212+00:00 gsa-tts-oros-fac.production.gsa-fac 5dac166f-2fb0-4e72-8d4d-4359191bf284 [APP/PROC/WEB/0] - [tags@47450 app_id="5dac166f-2fb0-4e72-8d4d-4359191bf284" app_name="gsa-fac" deployment="cf-production" index="569c864c-7d32-4f47-8c4b-677b7119c890" instance_id="0" ip="10.10.2.22" job="diego-cell" organization_id="d030fa77-d07d-4164-8f15-25dbc1c04f44" organization_name="gsa-tts-oros-fac" origin="rep" process_id="1f353158-8605-4e3a-b899-553ac9348987" process_instance_id="570ab03b-0525-4c56-7308-7164" process_type="web" source_id="5dac166f-2fb0-4e72-8d4d-4359191bf284" source_type="APP/PROC/WEB" space_id="5593dba8-7023-49a5-bdbe-e809fe23edf9" space_name="production"] {"message": "Internal Server Error: /report_submission/accessandsubmission/", "exc_info": "Traceback (most recent call last):\n File \"/home/vcap/deps/1/python/lib/python3.12/site-packages/django/db/backends/utils.py\", line 105, in _execute\n return self.cursor.execute(sql, params)\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"/home/vcap/deps/1/python/lib/python3.12/site-packages/newrelic/hooks/database_psycopg2.py\", line 54, in execute\n return super(CursorWrapper, self).execute(sql, parameters, *args, **kwargs)\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"/home/vcap/deps/1/python/lib/python3.12/site-packages/newrelic/hooks/database_dbapi2.py\", line 42, in execute\n return self.wrapped.execute(sql, parameters, *args, **kwargs)\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\npsycopg2.errors.UniqueViolation: duplicate key value violates unique constraint \"audit_singleauditchecklist_report_id_key\"\nDETAIL: Key (report_id)=(2023-06-GSAFAC-0000350231) already exists.\n\n\nThe above exception was the direct cause of the following exception:\n\nTraceback (most recent call last):\n File \"/home/vcap/deps/1/python/lib/python3.12/site-packages/django/core/handlers/exception.py\", line 55, in inner\n response = get_response(request)\n ^^^^^^^^^^^^^^^^^^^^^\n File \"/home/vcap/deps/1/python/lib/python3.12/site-packages/django/core/handlers/base.py\", line 197, in _get_response\n response = wrapped_callback(request, *callback_args, **callback_kwargs)\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"/home/vcap/deps/1/python/lib/python3.12/site-packages/newrelic/hooks/framework_django.py\", line 527, in wrapper\n return wrapped(*args, **kwargs)\n ^^^^^^^^^^^^^^^^^^^^^^^^\n File \"/home/vcap/deps/1/python/lib/python3.12/site-packages/django/views/generic/base.py\", line 104, in view\n return self.dispatch(request, *args, **kwargs)\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"/home/vcap/deps/1/python/lib/python3.12/site-packages/django/contrib/auth/mixins.py\", line 73, in dispatch\n return super().dispatch(request, *args, **kwargs)\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"/home/vcap/deps/1/python/lib/python3.12/site-packages/newrelic/hooks/framework_django.py\", line 900, in wrapper\n return wrapped(*args, **kwargs)\n ^^^^^^^^^^^^^^^^^^^^^^^^\n File \"/home/vcap/deps/1/python/lib/python3.12/site-packages/django/views/generic/base.py\", line 143, in dispatch\n return handler(request, *args, **kwargs)\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"/home/vcap/app/report_submission/views.py\", line 121, in post\n result = api.views.access_and_submission_check(request.user, request.POST)\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"/home/vcap/app/api/views.py\", line 114, in access_and_submission_check\n sac = SingleAuditChecklist.objects.create(\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"/home/vcap/app/audit/models/models.py\", line 106, in create\n result = super().create(**updated)\n ^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"/home/vcap/deps/1/python/lib/python3.12/site-packages/django/db/models/manager.py\", line 87, in manager_met",
"request": "<WSGIRequest: POST '/report_submission/accessandsubmission/'>",
"status_code": 500,
"tags.app_id": "5dac166f-2fb0-4e72-8d4d-4359191bf284",
"tags.app_name": "gsa-fac",
"tags.deployment": "cf-production",
"tags.index": "569c864c-7d32-4f47-8c4b-677b7119c890",
"tags.instance_id": "0",
"tags.ip": "10.10.2.22",
"tags.job": "diego-cell",
"tags.organization_id": "d030fa77-d07d-4164-8f15-25dbc1c04f44",
"tags.organization_name": "gsa-tts-oros-fac",
"tags.origin": "rep",
"tags.process_id": "1f353158-8605-4e3a-b899-553ac9348987",
"tags.process_instance_id": "570ab03b-0525-4c56-7308-7164",
"tags.process_type": "web",
"tags.source_id": "5dac166f-2fb0-4e72-8d4d-4359191bf284",
"tags.source_type": "APP/PROC/WEB",
"tags.space_id": "5593dba8-7023-49a5-bdbe-e809fe23edf9",
"tags.space_name": "production",
"taskName": "null",
"time": "2025-01-13T22:04:55.465212+00:00",
"timestamp": 1736805895465
}

@phildominguez-gsa phildominguez-gsa added the bug Something isn't working label Jan 16, 2025
@github-project-automation github-project-automation bot moved this to Triage in FAC Jan 16, 2025
@phildominguez-gsa phildominguez-gsa changed the title Bug: 500 error duplicate key violation for report_submission/accessandsubmission/ Bug: 500 error for report_submission/accessandsubmission/: Duplicate key violation Jan 16, 2025
@phildominguez-gsa phildominguez-gsa changed the title Bug: 500 error for report_submission/accessandsubmission/: Duplicate key violation Bug: 500 error for /report_submission/accessandsubmission: Duplicate key violation Jan 16, 2025
@rnovak338 rnovak338 self-assigned this Jan 30, 2025
@rnovak338 rnovak338 moved this from Triage to In Progress in FAC Jan 30, 2025
@rnovak338 rnovak338 moved this from In Progress to Done in FAC Feb 7, 2025
@rnovak338 rnovak338 moved this from Done to In Progress in FAC Feb 10, 2025
@rnovak338 rnovak338 moved this from In Progress to Done in FAC Feb 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Done
Development

No branches or pull requests

2 participants