fix(integration-map): let task sync update errors through instead of re-creating the task

Merged
CE
7d ago
+272-45

Problem

IntegrationMapSyncTaskHandler and IntegrationMapSyncIssueHandler wrap the integration-map lookup and the update of the mapped task in one try. Any failure of TaskUpdateCommand (validation, a DB error, a failing event handler) fell into the inner catch and ran TaskCreateCommand with the existing id, which renumbers the task and publishes its Created events again. If that create also failed, the outer catch took it for "no map yet" and created a brand-new task plus a second integration map for the same sourceId.

Fix

  • The integration map is looked up on its own; only a miss leads to "create task + map".
  • With a map, the mapped task is looked up on its own: if it exists, TaskUpdateCommand runs and its errors reach the caller; only when the mapped task no longer exists is it re-created under the mapped id (the existing intended behaviour).
  • Return values are unchanged.

Tests

New integration-map.sync-task.handler.spec.ts and integration-map.sync-issue.handler.spec.ts: an update failure with an existing map rejects and creates nothing; an existing map and task updates and returns the map; a missing map creates the task and its map once; an existing map with a missing task re-creates it with the mapped id without changing the input.

Notes

Not built or run locally.


Summary by cubic

Stops IntegrationMapSyncTaskHandler and IntegrationMapSyncIssueHandler from treating update or lookup failures as "not mapped yet", which previously created a second task and a second integration map for the same source ID. Only a NotFoundException on the map or mapped-task lookup leads to a create; any other error now reaches the caller instead of being converted into a duplicate task.

Tests

  • Added handler specs covering update failures, missing maps, missing mapped tasks, and non-NotFound lookup errors.