mitodl/mitxpro

IntegrityError: duplicate key value violates unique constraint "hubspot_api_unique_hubspot_id_type"

Opened this issue · 1 comments

Sentry Issue: XPRO-5YE

ApiException: (409)
Reason: Conflict
HTTP response headers: HTTPHeaderDict({'Date': 'Sun, 21 May 2023 19:53:37 GMT', 'Content-Type': 'application/json;charset=utf-8', 'Content-Length': '154', 'Connection': 'keep-alive', 'CF-Ray': '7caf5dda9d528287-IAD', 'Strict-Transport-Security': 'max-age=31536000; includeSubDomains; preload', 'Vary': 'origin, Accept-Encoding', 'CF-Cache-Status': 'DYNAMIC', 'Access-Control-Allow-Credentials': 'false', 'x-envoy-upstream-service-time': '80', 'x-evy-trace-listener': 'listener_https', 'x-evy-trace-route-configuration': 'listener_https/all', 'x-evy-trace-route-service-name': 'envoyset-translator', 'x-evy-trace-served-by-pod': 'iad02/hubapi-td/envoy-proxy-598c95b5b7-2nhmb', 'x-evy-trace-virtual-host': 'all', 'X-HubSpot-Correlation-Id': '7fb83cfe-cddc-452c-a990-d90f81515f6b', 'X-HubSpot-RateLimit-Daily': '500000', 'X-HubSpot-RateLimit-Daily-Remaining': '499942', 'X-HubSpot-RateLimit-Interval-Milliseconds': '10000', 'X-HubSpot-RateLimit-Max': '150', 'X-HubSpot-RateLimit-Remaining': '149', 'X-...
(3 additional frame(s) were not displayed)
...
  File "hubspot/crm/objects/api_client.py", line 345, in call_api
    return self.__call_api(
  File "hubspot/crm/objects/api_client.py", line 174, in __call_api
    response_data = self.request(
  File "hubspot/crm/objects/api_client.py", line 393, in request
    return self.rest_client.POST(url, query_params=query_params, headers=headers, post_params=post_params, _preload_content=_preload_content, _request_timeout=_request_timeout, body=body)
  File "hubspot/crm/objects/rest.py", line 206, in POST
    return self.request("POST", url, headers=headers, query_params=query_params, post_params=post_params, _preload_content=_preload_content, _request_timeout=_request_timeout, body=body)
  File "hubspot/crm/objects/rest.py", line 189, in request
    raise ApiException(http_resp=r)

HubspotObject.DoesNotExist: HubspotObject matching query does not exist.
  File "django/db/models/query.py", line 581, in get_or_create
    return self.get(**kwargs), False
  File "django/db/models/query.py", line 435, in get
    raise self.model.DoesNotExist(

UniqueViolation: duplicate key value violates unique constraint "hubspot_api_unique_hubspot_id_type"
DETAIL:  Key (hubspot_id, content_type_id)=(249004351, 38) already exists.

  File "django/db/backends/utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
  File "newrelic/hooks/database_psycopg2.py", line 64, in execute
    return super(CursorWrapper, self).execute(sql, parameters, *args,
  File "newrelic/hooks/database_dbapi2.py", line 37, in execute
    return self.__wrapped__.execute(sql, parameters,

IntegrityError: duplicate key value violates unique constraint "hubspot_api_unique_hubspot_id_type"
DETAIL:  Key (hubspot_id, content_type_id)=(249004351, 38) already exists.

(20 additional frame(s) were not displayed)
...
  File "hubspot_xpro/tasks.py", line 108, in sync_contact_with_hubspot
    return api.sync_contact_with_hubspot(user_id).id
  File "hubspot_xpro/api.py", line 617, in sync_contact_with_hubspot
    return upsert_object_request(

I think this has been fixed, I don't see any new errors getting reported on Sentry. Last one was 3 months ago.