Skip to content

WorkerConfiguration name unicity is not verified in (Partial)UpdateConfiguration

Sentry Issue: ARKINDEX-BACKEND-1E7

UniqueViolation: duplicate key value violates unique constraint "dataimport_workerconfiguration_worker_id_name_c82a4531_uniq"
DETAIL:  Key (worker_id, name)=(a68f31f0-99ce-4281-af45-48344a2ec671, aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) already exists.

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

IntegrityError: duplicate key value violates unique constraint "dataimport_workerconfiguration_worker_id_name_c82a4531_uniq"
DETAIL:  Key (worker_id, name)=(a68f31f0-99ce-4281-af45-48344a2ec671, aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) already exists.

(22 additional frame(s) were not displayed)
...
  File "django/db/backends/utils.py", line 67, in execute
    return self._execute_with_wrappers(
  File "django/db/backends/utils.py", line 80, in _execute_with_wrappers
    return executor(sql, params, many, context)
  File "django/db/backends/utils.py", line 89, in _execute
    return self.cursor.execute(sql, params)
  File "django/db/utils.py", line 91, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "django/db/backends/utils.py", line 89, in _execute
    return self.cursor.execute(sql, params)

To reproduce in the API client:

>>> worker_id = next(cli.paginate('ListWorkers'))["id"]
>>> conf1 = cli.request('CreateWorkerConfiguration', id=worker_id, body={"name": "a", "configuration": {"a": "b"}})
>>> conf2 = cli.request('CreateWorkerConfiguration', id=worker_id, body={"name": "aa", "configuration": {"aa": "bb"}})
>>> cli.request('PartialUpdateWorkerConfiguration', id=conf2["id"], body={"name": "a"})
ErrorResponse: '\n<!doctype html>\n<html lang="en">\n<head>\n  <title>Server Error (500)</title>\n</head>\n<body>\n  <h1>Server Error (500)</h1><p></p>\n</body>\n</html>\n'