fix: do not recreate tasks that already have the derived UUID
All checks were successful
CI Smoke / host-smoke (push) Successful in 1s
CI Smoke / container-smoke (push) Successful in 2s
Build and Publish Multi-Context Image / build-and-push (push) Successful in 25s

Registrar-minted tasks keep the derived UUID with record_id unset.
Inserting them again collides. Match by UUID, then write record_id.

Assistant: grok
Assistant-Session: 01a04996-76e8-7f53-b971-1885cfbed436
This commit is contained in:
tegwick 2026-08-28 21:31:13 +02:00
parent 43e3edd727
commit 54b09ee9e2
2 changed files with 26 additions and 4 deletions

View file

@ -671,18 +671,25 @@ def _sync_existing_workplan_tasks(
if t.record_id and t.record_id.strip()
}
matched: dict[str, Any] = {}
claimed: set[str] = set()
stale: list[Any] = []
by_uuid = {str(ht.id): ht for ht in hub_tasks}
for ht in hub_tasks:
rid = (ht.record_id or "").strip().lower()
if not rid:
continue
if rid in want:
if rid and rid in want:
matched[rid] = ht
else:
claimed.add(str(ht.id))
elif rid:
stale.append(ht)
for key, dt in want.items():
ht = matched.get(key)
if ht is None and dt.uuid in by_uuid:
# Already on the hub under the derived UUID, but record_id was never
# written (the registrar-minted case). Overwriting would collide.
ht = by_uuid[dt.uuid]
matched[key] = ht
claimed.add(str(ht.id))
if ht is None:
kwargs: dict[str, Any] = {
"id": uuid.UUID(dt.uuid),
@ -702,6 +709,9 @@ def _sync_existing_workplan_tasks(
outcome.created_tasks.append(dt.record_id)
continue
changed = False
if not (ht.record_id or "").strip():
ht.record_id = dt.record_id
changed = True
if dt.title and dt.title.strip() and ht.title != dt.title.strip():
ht.title = dt.title.strip()
changed = True