Skip to content

Commit 8dc38bd

Browse files
committed
fix: improve error handling in target resolution
1 parent 2a8a3e2 commit 8dc38bd

1 file changed

Lines changed: 13 additions & 8 deletions

File tree

src/Migration/Destinations/Appwrite.php

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1849,15 +1849,20 @@ private function resolveMessageTargets(Message $resource): array
18491849
continue;
18501850
}
18511851

1852-
if (!isset($targetCache[$userId])) {
1853-
$targetCache[$userId] = $this->users->listTargets($userId);
1854-
}
1852+
try {
1853+
if (!isset($targetCache[$userId])) {
1854+
$targetCache[$userId] = $this->users->listTargets($userId);
1855+
}
18551856

1856-
foreach ($targetCache[$userId]['targets'] as $target) {
1857-
if ($target['providerType'] === $providerType) {
1858-
$resolvedTargets[] = $target['$id'];
1859-
break;
1857+
foreach ($targetCache[$userId]['targets'] as $target) {
1858+
if ($target['providerType'] === $providerType) {
1859+
$resolvedTargets[] = $target['$id'];
1860+
break;
1861+
}
18601862
}
1863+
} catch (\Throwable $e) {
1864+
// Skip targets for users that don't exist on the destination
1865+
continue;
18611866
}
18621867
}
18631868

@@ -1880,6 +1885,6 @@ private function resolveTargetId(Subscriber $resource): string
18801885
}
18811886
}
18821887

1883-
return $resource->getTargetId();
1888+
throw new \Exception('No matching target found for subscriber ' . $resource->getId() . ' with providerType ' . $resource->getProviderType());
18841889
}
18851890
}

0 commit comments

Comments
 (0)