diff --git a/connector-superoffice/worker.py b/connector-superoffice/worker.py index 2bd593f6..0d953c72 100644 --- a/connector-superoffice/worker.py +++ b/connector-superoffice/worker.py @@ -52,7 +52,7 @@ def process_job(job, so_client: SuperOfficeClient, queue: JobQueue): return ("SKIPPED", msg) # -------------------------------------------- - # 0. Noise Reduction: Filter irrelevant field changes + # 0. ID Extraction & Early Exit for irrelevant jobs person_id = None contact_id = None job_title = payload.get("JobTitle") @@ -77,6 +77,12 @@ def process_job(job, so_client: SuperOfficeClient, queue: JobQueue): elif "PrimaryKey" in payload and "contact" in event_low: contact_id = int(payload["PrimaryKey"]) + # If after all checks, we have no ID, we can't process it. + if not person_id and not contact_id: + msg = f"Skipping job: No ContactId or PersonId could be identified in the payload." + logger.warning(msg) + return ("SKIPPED", msg) + # Fallback/Deep Lookup & Fetch JobTitle if missing if person_id and (not job_title or not contact_id): try: