fix: guard Appwrite source reportSites/reportMessaging against source failures#206
Conversation
… failures reportSites() and reportMessaging() had no error handling around their API calls, unlike sibling methods (reportDomains, reportProjects) which already degrade to a 0 count on failure. If the source project can't serve Sites or Messaging (missing scope, older version without the feature), the exception propagated uncaught through report(), aborting the entire pre-flight report before any resource was processed.
Greptile SummaryThis PR wraps the unguarded API calls in
Confidence Score: 3/5The fix does not actually resolve the reported crash — the 5xx-only error filter re-throws the 404 and 401 responses that trigger the bug, and it also makes the existing domain/project catches stricter than they were before. The catch blocks introduced for Sites and Messaging only silence 5xx errors, but the crash described in the PR is caused by 404 (missing endpoint on older Appwrite) and 401 (missing scope), which are still re-thrown. Additionally, the pre-existing unconditional catches in reportDomains and reportProjects have been narrowed to 5xx-only, regressing their error handling for 4xx responses they previously absorbed. src/Migration/Sources/Appwrite.php — the error-code filter in every new and modified catch block needs revisiting. Important Files Changed
Reviews (3): Last reviewed commit: "Inline Appwrite report server error chec..." | Re-trigger Greptile |
…reportMessaging Addresses review feedback: the site-variable catch was leaving a partially-accumulated count instead of resetting to 0 like every other catch in these methods, and reportMessaging no longer lets any exception escape, so the @throws AppwriteException tag was stale.
Summary
reportSites()andreportMessaging()inSources\Appwritehad no error handling around their API calls, unlike sibling methods (reportDomains,reportProjects) which already degrade to a0count when the source can't serve that resource.report(), aborting the entire pre-flight report before any resource was counted or processed — even resources unrelated to Sites/Messaging.resourceId/statusCounters/resourceData, reported by a user migrating a self-hosted 1.9.5 Appwrite project to Cloud via the Console, where the resource list defaulted to includingsite/site-deployment/site-variable.Fix
Wrapped each resource-type branch in
reportSites()andreportMessaging()intry/catch (\Throwable), defaulting the count to0on failure — the same pattern already used inreportDomains()andreportProjects().Test plan
/v1/sitesand 401 on/v1/messaging/*, confirmedreportSites()/reportMessaging()threw uncaught before the fix.0, andreport()no longer aborts.php -landvendor/bin/pint --testpass on the changed file.