Multiple calls to CreateElementChildren may fail due to bad ordering
Sentry issue : https://teklia.sentry.io/issues/5770532618
Refs https://redmine.teklia.com/issues/8477 - source of failures for socface publication, probably will be
The crash comes from PG :
RaiseException: Each element within a parent must have a distinct ordering
CONTEXT: PL/pgSQL function pgtrigger_unique_parent_orderings_bbcd7() line 21 at RAISE
This happens when an household element already has some text lines as children, and get a second call with new elements to add to the household.
Sample code to reproduce
import os
import apistar.exceptions
from arkindex import ArkindexClient
client = ArkindexClient(base_url="https://arkindex.teklia.com", token=os.environ.get("ARKINDEX_API_TOKEN"))
children = ['842240a4-3da0-472f-a3e6-c6d3b50240af', 'b361783e-b353-4a89-b0b6-014a7ea82a03', '889f1a0c-bf61-4926-84b1-24597990f0aa', '4a7446f8-fa2d-445a-99e0-fa6586ac48cf', 'f0066802-b963-45c7-aa5b-0acb8428f79d', 'c73b5223-f177-4caa-be8b-57906c93e097', '59efe206-0f27-4c31-820c-2967682bcf63', '81e41265-8c6b-429f-a531-84fd6f450065', '4b829047-9bad-43d5-a3e6-4fcd83dd9966', 'ad0dc80f-f124-4b5b-bca4-c1857d30c701', 'f1b65d1e-a3da-4b52-a960-0084312f467f', '53056041-d2f2-4dc3-b5f4-c6c72d6020b2', 'c79a0c98-8588-4860-a11b-221069837bd0', '193218e1-085f-43b8-aa2e-0176a9c3ba50', '0d1915f8-f7a0-415b-a5fe-476817a845df', 'fe21e755-5cac-4c34-9bbb-b0a6da9f065e', '6e46548d-c014-41fc-9a5a-88bf2886e528', '5c69c43e-23ab-4bb4-bffb-01b8229478d2', '1fd532e6-578e-4a4b-b021-07a4ebf38424', '51c032ef-5763-4971-8404-75057d78d816', '0362f33a-f39a-40e9-8876-56e099645634', '69a4074e-003f-46cb-bde0-7f92a5f36c6a', 'e5bd378e-5b84-45ee-84df-3a6c7c30335a', 'f75bdaf6-df11-4642-968e-9f9152cccf64', 'cc753f62-cac8-4b5c-a35b-737326bc9126', '0c427f2e-aa74-494e-9b74-7f9bc2648a84', 'd22bac31-da0a-42bb-9e0f-2b71085b177a', '96948b22-639c-4ec9-a129-0edd208edb17', '8bc849db-111c-4e52-b8ab-27cd1e891772', '4d7495e0-d4ef-49af-a766-47edd97b887c', '03cbc0dd-726f-4aa1-8f51-5d09a9f21622', '518f2d07-4e51-4006-b130-f57aca34156d', '29de4668-a387-4f06-b262-120478d769da', '4df3340f-26a2-4008-b67b-3f679b38f692', '1a5c624b-e2e9-4b08-8770-0abf4e0091ce', '63b05983-9fe5-4176-9a1b-4064c255c141', '28380d1f-66a8-4149-80e7-2a63df17a261', '629958c5-f618-45e2-bad6-1519b5b85a4d', '38a9dde5-94fd-400e-9d28-d04c6760dc4b', '7be053d5-aa06-4bbb-82b4-5ea27e8bac8d', '1d199907-ce16-4889-a658-c36d38876ad4', 'ec208eb2-b8c8-4fb0-b119-d2a7ebee7524']
try:
client.request('CreateElementChildren', id="999f9f5d-b9ff-4b4f-8c13-04d25fe35eab", body={'children': children})
except apistar.exceptions.ErrorResponse as e:
print(f"Error {e.status_code}: {e.content}")
Edited by Bastien Abadie