From 39a249231c9e2064969040a96bf5a7d56b91ff9d Mon Sep 17 00:00:00 2001 From: Prem Palanisamy Date: Mon, 4 May 2026 07:51:33 +0100 Subject: [PATCH 1/8] Stop user-data errors leaking to Sentry from migrations Two changes in Destinations/Appwrite.php: 1. Per-resource wrap rethrows non-Migration\Exception throwables. User errors still record on the migration document and the loop continues (existing behaviour). Library bugs and infra failures now bubble to the worker boundary so they can be routed to Sentry instead of being silently absorbed. 2. Row-flush match block catches DuplicateException and StructureException from the database adapter and rethrows them as Migration\Exception so the per-resource wrap above recognises them as user-facing failures. This keeps "Document already exists" / invalid structure messages in the migration report only. --- src/Migration/Destinations/Appwrite.php | 51 +++++++++++++++++++------ 1 file changed, 39 insertions(+), 12 deletions(-) diff --git a/src/Migration/Destinations/Appwrite.php b/src/Migration/Destinations/Appwrite.php index 81ee6b2fda..daaad0a135 100644 --- a/src/Migration/Destinations/Appwrite.php +++ b/src/Migration/Destinations/Appwrite.php @@ -344,6 +344,13 @@ class Appwrite extends Destination previous: $e )); + // User-facing failures (Migration\Exception) are recorded for the migration + // report and the loop continues. Anything else is a library bug or infra + // failure — rethrow so the worker boundary can route it to Sentry. + if (!$e instanceof Exception) { + throw $e; + } + $responseResource = $resource; } finally { $this->dbForProject->setPreserveDates(false); @@ -1074,19 +1081,39 @@ class Appwrite extends Destination } $collectionId = 'database_' . $databaseInternalId . '_collection_' . $tableInternalId; - match ($this->onDuplicate) { - OnDuplicate::Upsert => $dbForDatabases->skipRelationshipsExistCheck( - fn () => $dbForDatabases->upsertDocuments($collectionId, $this->rowBuffer) - ), - OnDuplicate::Skip => $dbForDatabases->skipDuplicates( - fn () => $dbForDatabases->skipRelationshipsExistCheck( + try { + match ($this->onDuplicate) { + OnDuplicate::Upsert => $dbForDatabases->skipRelationshipsExistCheck( + fn () => $dbForDatabases->upsertDocuments($collectionId, $this->rowBuffer) + ), + OnDuplicate::Skip => $dbForDatabases->skipDuplicates( + fn () => $dbForDatabases->skipRelationshipsExistCheck( + fn () => $dbForDatabases->createDocuments($collectionId, $this->rowBuffer) + ) + ), + OnDuplicate::Fail => $dbForDatabases->skipRelationshipsExistCheck( fn () => $dbForDatabases->createDocuments($collectionId, $this->rowBuffer) - ) - ), - OnDuplicate::Fail => $dbForDatabases->skipRelationshipsExistCheck( - fn () => $dbForDatabases->createDocuments($collectionId, $this->rowBuffer) - ), - }; + ), + }; + } catch (DuplicateException $e) { + // Convert to Migration\Exception so the per-resource wrap recognises it + // as a user-facing failure and records it without escalating to Sentry. + throw new Exception( + resourceName: $resource->getName(), + resourceGroup: $resource->getGroup(), + resourceId: $resource->getId(), + message: 'Document already exists', + previous: $e, + ); + } catch (StructureException $e) { + throw new Exception( + resourceName: $resource->getName(), + resourceGroup: $resource->getGroup(), + resourceId: $resource->getId(), + message: $e->getMessage(), + previous: $e, + ); + } } finally { $this->rowBuffer = []; } From 276e7c25077a4dee670a806f715869f11367d932 Mon Sep 17 00:00:00 2001 From: Prem Palanisamy Date: Mon, 4 May 2026 08:20:31 +0100 Subject: [PATCH 2/8] Stop user-data errors leaking to Sentry from migrations MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Convert per-resource user-error throws into setStatus + addError + return false in the create*() methods (createDatabase, createEntity, createField, createIndex, createRecord). Failures are recorded for the migration report where they're detected, and the import loop continues to the next resource — matching the existing skip-from-cache pattern at line 1015 and the documents-DB skip at line 535. The per-resource wrap at import() simplifies to a pure safety net: record for the user, then rethrow. By construction, anything reaching it is a library bug or infra failure, which the worker boundary routes to Sentry. Row-flush DuplicateException / StructureException are caught at the flush site and recorded inline — same shape as the rest of the create*() methods. Behaviour preserved: user errors continue to appear in the migration report, the loop continues across resources, the migration ends with status=failed when any resource failed. Only routing to Sentry changed. --- src/Migration/Destinations/Appwrite.php | 147 +++++++++++++++--------- 1 file changed, 93 insertions(+), 54 deletions(-) diff --git a/src/Migration/Destinations/Appwrite.php b/src/Migration/Destinations/Appwrite.php index daaad0a135..fab054399c 100644 --- a/src/Migration/Destinations/Appwrite.php +++ b/src/Migration/Destinations/Appwrite.php @@ -333,6 +333,10 @@ class Appwrite extends Destination default => throw new \Exception('Invalid resource group', Exception::CODE_VALIDATION), }; } catch (\Throwable $e) { + // Safety net: expected user-data failures are recorded inline by the + // create*() methods via setStatus + addError + return false. Anything + // reaching here is a library bug or infra failure — record it for the + // user, then rethrow so the worker boundary can route it to Sentry. $resource->setStatus(Resource::STATUS_ERROR, $e->getMessage()); $this->addError(new Exception( @@ -344,14 +348,7 @@ class Appwrite extends Destination previous: $e )); - // User-facing failures (Migration\Exception) are recorded for the migration - // report and the loop continues. Anything else is a library bug or infra - // failure — rethrow so the worker boundary can route it to Sentry. - if (!$e instanceof Exception) { - throw $e; - } - - $responseResource = $resource; + throw $e; } finally { $this->dbForProject->setPreserveDates(false); } @@ -421,12 +418,14 @@ class Appwrite extends Destination $validator = new UID(); if (!$validator->isValid($resource->getId())) { - throw new Exception( + $resource->setStatus(Resource::STATUS_ERROR, $validator->getDescription()); + $this->addError(new Exception( resourceName: $resource->getName(), resourceGroup: $resource->getGroup(), resourceId: $resource->getId(), message: $validator->getDescription(), - ); + )); + return false; } $createdAt = $this->normalizeDateTime($resource->getCreatedAt()); @@ -481,12 +480,14 @@ class Appwrite extends Destination $validator = new UID(); if (!$validator->isValid($resource->getId())) { - throw new Exception( + $resource->setStatus(Resource::STATUS_ERROR, $validator->getDescription()); + $this->addError(new Exception( resourceName: $resource->getName(), resourceGroup: $resource->getGroup(), resourceId: $resource->getId(), message: $validator->getDescription(), - ); + )); + return false; } $database = $this->dbForProject->getDocument( @@ -495,12 +496,14 @@ class Appwrite extends Destination ); if ($database->isEmpty()) { - throw new Exception( + $resource->setStatus(Resource::STATUS_ERROR, 'Database not found'); + $this->addError(new Exception( resourceName: $resource->getName(), resourceGroup: $resource->getGroup(), resourceId: $resource->getId(), message: 'Database not found', - ); + )); + return false; } $createdAt = $this->normalizeDateTime($resource->getCreatedAt()); @@ -582,12 +585,14 @@ class Appwrite extends Destination ); if ($database->isEmpty()) { - throw new Exception( + $resource->setStatus(Resource::STATUS_ERROR, 'Database not found'); + $this->addError(new Exception( resourceName: $resource->getName(), resourceGroup: $resource->getGroup(), resourceId: $resource->getId(), message: 'Database not found', - ); + )); + return false; } $table = $this->dbForProject->getDocument( @@ -596,41 +601,49 @@ class Appwrite extends Destination ); if ($table->isEmpty()) { - throw new Exception( + $resource->setStatus(Resource::STATUS_ERROR, 'Table not found'); + $this->addError(new Exception( resourceName: $resource->getName(), resourceGroup: $resource->getGroup(), resourceId: $resource->getId(), message: 'Table not found', - ); + )); + return false; } if (!empty($resource->getFormat())) { if (!Structure::hasFormat($resource->getFormat(), $type)) { - throw new Exception( + $resource->setStatus(Resource::STATUS_ERROR, "Format {$resource->getFormat()} not available for column type {$type}"); + $this->addError(new Exception( resourceName: $resource->getName(), resourceGroup: $resource->getGroup(), resourceId: $resource->getId(), message: "Format {$resource->getFormat()} not available for column type {$type}", - ); + )); + return false; } } if ($resource->isRequired() && $resource->getDefault() !== null) { - throw new Exception( + $resource->setStatus(Resource::STATUS_ERROR, 'Cannot set default value for required column'); + $this->addError(new Exception( resourceName: $resource->getName(), resourceGroup: $resource->getGroup(), resourceId: $resource->getId(), message: 'Cannot set default value for required column', - ); + )); + return false; } if ($resource->isArray() && $resource->getDefault() !== null) { - throw new Exception( + $resource->setStatus(Resource::STATUS_ERROR, 'Cannot set default value for array column'); + $this->addError(new Exception( resourceName: $resource->getName(), resourceGroup: $resource->getGroup(), resourceId: $resource->getId(), message: 'Cannot set default value for array column', - ); + )); + return false; } if ($type === UtopiaDatabase::VAR_RELATIONSHIP) { @@ -640,12 +653,14 @@ class Appwrite extends Destination $resource->getOptions()['relatedCollection'] ); if ($relatedTable->isEmpty()) { - throw new Exception( + $resource->setStatus(Resource::STATUS_ERROR, 'Related table not found'); + $this->addError(new Exception( resourceName: $resource->getName(), resourceGroup: $resource->getGroup(), resourceId: $resource->getId(), message: 'Related table not found', - ); + )); + return false; } } @@ -678,20 +693,26 @@ class Appwrite extends Destination $this->dbForProject->checkAttribute($table, $column); $column = $this->dbForProject->createDocument('attributes', $column); - } catch (DuplicateException) { - throw new Exception( + } catch (DuplicateException $e) { + $resource->setStatus(Resource::STATUS_ERROR, 'Attribute already exists'); + $this->addError(new Exception( resourceName: $resource->getName(), resourceGroup: $resource->getGroup(), resourceId: $resource->getId(), message: 'Attribute already exists', - ); - } catch (LimitException) { - throw new Exception( + previous: $e, + )); + return false; + } catch (LimitException $e) { + $resource->setStatus(Resource::STATUS_ERROR, 'Attribute limit exceeded'); + $this->addError(new Exception( resourceName: $resource->getName(), resourceGroup: $resource->getGroup(), resourceId: $resource->getId(), message: 'Attribute limit exceeded', - ); + previous: $e, + )); + return false; } catch (\Throwable $e) { $this->dbForProject->purgeCachedDocument('database_' . $database->getSequence(), $table->getId()); $dbForDatabases->purgeCachedCollection('database_' . $database->getSequence() . '_collection_' . $table->getSequence()); @@ -734,24 +755,30 @@ class Appwrite extends Destination ]); $this->dbForProject->createDocument('attributes', $twoWayAttribute); - } catch (DuplicateException) { + } catch (DuplicateException $e) { $this->dbForProject->deleteDocument('attributes', $column->getId()); - throw new Exception( + $resource->setStatus(Resource::STATUS_ERROR, 'Attribute already exists'); + $this->addError(new Exception( resourceName: $resource->getName(), resourceGroup: $resource->getGroup(), resourceId: $resource->getId(), message: 'Attribute already exists', - ); - } catch (LimitException) { + previous: $e, + )); + return false; + } catch (LimitException $e) { $this->dbForProject->deleteDocument('attributes', $column->getId()); - throw new Exception( + $resource->setStatus(Resource::STATUS_ERROR, 'Column limit exceeded'); + $this->addError(new Exception( resourceName: $resource->getName(), resourceGroup: $resource->getGroup(), resourceId: $resource->getId(), message: 'Column limit exceeded', - ); + previous: $e, + )); + return false; } catch (\Throwable $e) { $this->dbForProject->purgeCachedDocument('database_' . $database->getSequence(), $relatedTable->getId()); $dbForDatabases->purgeCachedCollection('database_' . $database->getSequence() . '_collection_' . $relatedTable->getSequence()); @@ -832,12 +859,14 @@ class Appwrite extends Destination $resource->getTable()->getDatabase()->getId(), ); if ($database->isEmpty()) { - throw new Exception( + $resource->setStatus(Resource::STATUS_ERROR, 'Database not found'); + $this->addError(new Exception( resourceName: $resource->getName(), resourceGroup: $resource->getGroup(), resourceId: $resource->getId(), message: 'Database not found', - ); + )); + return false; } $table = $this->dbForProject->getDocument( @@ -845,12 +874,14 @@ class Appwrite extends Destination $resource->getTable()->getId(), ); if ($table->isEmpty()) { - throw new Exception( + $resource->setStatus(Resource::STATUS_ERROR, 'Table not found'); + $this->addError(new Exception( resourceName: $resource->getName(), resourceGroup: $resource->getGroup(), resourceId: $resource->getId(), message: 'Table not found', - ); + )); + return false; } $dbForDatabases = ($this->getDatabasesDB)($database); @@ -860,12 +891,14 @@ class Appwrite extends Destination ], $dbForDatabases->getLimitForIndexes()); if ($count >= $dbForDatabases->getLimitForIndexes()) { - throw new Exception( + $resource->setStatus(Resource::STATUS_ERROR, 'Index limit reached for table'); + $this->addError(new Exception( resourceName: $resource->getName(), resourceGroup: $resource->getGroup(), resourceId: $resource->getId(), message: 'Index limit reached for table', - ); + )); + return false; } // Lengths hidden by default @@ -922,12 +955,14 @@ class Appwrite extends Destination if (!$validator->isValid($index)) { - throw new Exception( + $resource->setStatus(Resource::STATUS_ERROR, 'Invalid index: ' . $validator->getDescription()); + $this->addError(new Exception( resourceName: $resource->getName(), resourceGroup: $resource->getGroup(), resourceId: $resource->getId(), message: 'Invalid index: ' . $validator->getDescription(), - ); + )); + return false; } $index = $this->dbForProject->createDocument('indexes', $index); @@ -984,12 +1019,14 @@ class Appwrite extends Destination $validator = new UID(); if (!$validator->isValid($resource->getId())) { - throw new Exception( + $resource->setStatus(Resource::STATUS_ERROR, $validator->getDescription()); + $this->addError(new Exception( resourceName: $resource->getName(), resourceGroup: $resource->getGroup(), resourceId: $resource->getId(), message: $validator->getDescription(), - ); + )); + return false; } // Check if document has already been created @@ -1096,23 +1133,25 @@ class Appwrite extends Destination ), }; } catch (DuplicateException $e) { - // Convert to Migration\Exception so the per-resource wrap recognises it - // as a user-facing failure and records it without escalating to Sentry. - throw new Exception( + $resource->setStatus(Resource::STATUS_ERROR, 'Document already exists'); + $this->addError(new Exception( resourceName: $resource->getName(), resourceGroup: $resource->getGroup(), resourceId: $resource->getId(), message: 'Document already exists', previous: $e, - ); + )); + return false; } catch (StructureException $e) { - throw new Exception( + $resource->setStatus(Resource::STATUS_ERROR, $e->getMessage()); + $this->addError(new Exception( resourceName: $resource->getName(), resourceGroup: $resource->getGroup(), resourceId: $resource->getId(), message: $e->getMessage(), previous: $e, - ); + )); + return false; } } finally { $this->rowBuffer = []; From 0710fde3a99f7236f8bbcf2bf5fc860da0378535 Mon Sep 17 00:00:00 2001 From: Prem Palanisamy Date: Mon, 4 May 2026 11:03:40 +0100 Subject: [PATCH 3/8] Combine Duplicate/Structure catches at row-flush; trim verbose comments DB adapters already normalise DuplicateException's message to 'Document already exists', so a multi-type catch with $e->getMessage() collapses both branches into one without changing user-visible behaviour. Trimmed the safety-net comment to a single line. --- src/Migration/Destinations/Appwrite.php | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/src/Migration/Destinations/Appwrite.php b/src/Migration/Destinations/Appwrite.php index fab054399c..67a20a15c7 100644 --- a/src/Migration/Destinations/Appwrite.php +++ b/src/Migration/Destinations/Appwrite.php @@ -333,10 +333,8 @@ class Appwrite extends Destination default => throw new \Exception('Invalid resource group', Exception::CODE_VALIDATION), }; } catch (\Throwable $e) { - // Safety net: expected user-data failures are recorded inline by the - // create*() methods via setStatus + addError + return false. Anything - // reaching here is a library bug or infra failure — record it for the - // user, then rethrow so the worker boundary can route it to Sentry. + // Safety net for unexpected failures — record on the migration and + // rethrow so the worker boundary can route bugs to Sentry. $resource->setStatus(Resource::STATUS_ERROR, $e->getMessage()); $this->addError(new Exception( @@ -1132,17 +1130,7 @@ class Appwrite extends Destination fn () => $dbForDatabases->createDocuments($collectionId, $this->rowBuffer) ), }; - } catch (DuplicateException $e) { - $resource->setStatus(Resource::STATUS_ERROR, 'Document already exists'); - $this->addError(new Exception( - resourceName: $resource->getName(), - resourceGroup: $resource->getGroup(), - resourceId: $resource->getId(), - message: 'Document already exists', - previous: $e, - )); - return false; - } catch (StructureException $e) { + } catch (DuplicateException | StructureException $e) { $resource->setStatus(Resource::STATUS_ERROR, $e->getMessage()); $this->addError(new Exception( resourceName: $resource->getName(), From 3fdcd279254e41e323d64b95e7efafe5b9bab19f Mon Sep 17 00:00:00 2001 From: Prem Palanisamy Date: Mon, 4 May 2026 11:06:03 +0100 Subject: [PATCH 4/8] Combine Duplicate/Limit catches in createField Same shape as the row-flush combine: multi-type catch with a small ternary for the per-type message. Two pairs collapsed: the single attribute path and the relationship two-way path (which differ only in 'Attribute limit exceeded' vs 'Column limit exceeded'). --- src/Migration/Destinations/Appwrite.php | 36 ++++++------------------- 1 file changed, 8 insertions(+), 28 deletions(-) diff --git a/src/Migration/Destinations/Appwrite.php b/src/Migration/Destinations/Appwrite.php index 67a20a15c7..22fc0efe61 100644 --- a/src/Migration/Destinations/Appwrite.php +++ b/src/Migration/Destinations/Appwrite.php @@ -691,23 +691,14 @@ class Appwrite extends Destination $this->dbForProject->checkAttribute($table, $column); $column = $this->dbForProject->createDocument('attributes', $column); - } catch (DuplicateException $e) { - $resource->setStatus(Resource::STATUS_ERROR, 'Attribute already exists'); + } catch (DuplicateException | LimitException $e) { + $message = $e instanceof DuplicateException ? 'Attribute already exists' : 'Attribute limit exceeded'; + $resource->setStatus(Resource::STATUS_ERROR, $message); $this->addError(new Exception( resourceName: $resource->getName(), resourceGroup: $resource->getGroup(), resourceId: $resource->getId(), - message: 'Attribute already exists', - previous: $e, - )); - return false; - } catch (LimitException $e) { - $resource->setStatus(Resource::STATUS_ERROR, 'Attribute limit exceeded'); - $this->addError(new Exception( - resourceName: $resource->getName(), - resourceGroup: $resource->getGroup(), - resourceId: $resource->getId(), - message: 'Attribute limit exceeded', + message: $message, previous: $e, )); return false; @@ -753,27 +744,16 @@ class Appwrite extends Destination ]); $this->dbForProject->createDocument('attributes', $twoWayAttribute); - } catch (DuplicateException $e) { + } catch (DuplicateException | LimitException $e) { $this->dbForProject->deleteDocument('attributes', $column->getId()); - $resource->setStatus(Resource::STATUS_ERROR, 'Attribute already exists'); + $message = $e instanceof DuplicateException ? 'Attribute already exists' : 'Column limit exceeded'; + $resource->setStatus(Resource::STATUS_ERROR, $message); $this->addError(new Exception( resourceName: $resource->getName(), resourceGroup: $resource->getGroup(), resourceId: $resource->getId(), - message: 'Attribute already exists', - previous: $e, - )); - return false; - } catch (LimitException $e) { - $this->dbForProject->deleteDocument('attributes', $column->getId()); - - $resource->setStatus(Resource::STATUS_ERROR, 'Column limit exceeded'); - $this->addError(new Exception( - resourceName: $resource->getName(), - resourceGroup: $resource->getGroup(), - resourceId: $resource->getId(), - message: 'Column limit exceeded', + message: $message, previous: $e, )); return false; From 7bb1da14e1c320bc32c67f47e7f3b251823200f9 Mon Sep 17 00:00:00 2001 From: Prem Palanisamy Date: Mon, 4 May 2026 11:11:24 +0100 Subject: [PATCH 5/8] Revert catch combines; keep typed catches separate --- src/Migration/Destinations/Appwrite.php | 48 ++++++++++++++++++++----- 1 file changed, 39 insertions(+), 9 deletions(-) diff --git a/src/Migration/Destinations/Appwrite.php b/src/Migration/Destinations/Appwrite.php index 22fc0efe61..e7e4fc535a 100644 --- a/src/Migration/Destinations/Appwrite.php +++ b/src/Migration/Destinations/Appwrite.php @@ -691,14 +691,23 @@ class Appwrite extends Destination $this->dbForProject->checkAttribute($table, $column); $column = $this->dbForProject->createDocument('attributes', $column); - } catch (DuplicateException | LimitException $e) { - $message = $e instanceof DuplicateException ? 'Attribute already exists' : 'Attribute limit exceeded'; - $resource->setStatus(Resource::STATUS_ERROR, $message); + } catch (DuplicateException $e) { + $resource->setStatus(Resource::STATUS_ERROR, 'Attribute already exists'); $this->addError(new Exception( resourceName: $resource->getName(), resourceGroup: $resource->getGroup(), resourceId: $resource->getId(), - message: $message, + message: 'Attribute already exists', + previous: $e, + )); + return false; + } catch (LimitException $e) { + $resource->setStatus(Resource::STATUS_ERROR, 'Attribute limit exceeded'); + $this->addError(new Exception( + resourceName: $resource->getName(), + resourceGroup: $resource->getGroup(), + resourceId: $resource->getId(), + message: 'Attribute limit exceeded', previous: $e, )); return false; @@ -744,16 +753,27 @@ class Appwrite extends Destination ]); $this->dbForProject->createDocument('attributes', $twoWayAttribute); - } catch (DuplicateException | LimitException $e) { + } catch (DuplicateException $e) { $this->dbForProject->deleteDocument('attributes', $column->getId()); - $message = $e instanceof DuplicateException ? 'Attribute already exists' : 'Column limit exceeded'; - $resource->setStatus(Resource::STATUS_ERROR, $message); + $resource->setStatus(Resource::STATUS_ERROR, 'Attribute already exists'); $this->addError(new Exception( resourceName: $resource->getName(), resourceGroup: $resource->getGroup(), resourceId: $resource->getId(), - message: $message, + message: 'Attribute already exists', + previous: $e, + )); + return false; + } catch (LimitException $e) { + $this->dbForProject->deleteDocument('attributes', $column->getId()); + + $resource->setStatus(Resource::STATUS_ERROR, 'Column limit exceeded'); + $this->addError(new Exception( + resourceName: $resource->getName(), + resourceGroup: $resource->getGroup(), + resourceId: $resource->getId(), + message: 'Column limit exceeded', previous: $e, )); return false; @@ -1110,7 +1130,17 @@ class Appwrite extends Destination fn () => $dbForDatabases->createDocuments($collectionId, $this->rowBuffer) ), }; - } catch (DuplicateException | StructureException $e) { + } catch (DuplicateException $e) { + $resource->setStatus(Resource::STATUS_ERROR, 'Document already exists'); + $this->addError(new Exception( + resourceName: $resource->getName(), + resourceGroup: $resource->getGroup(), + resourceId: $resource->getId(), + message: 'Document already exists', + previous: $e, + )); + return false; + } catch (StructureException $e) { $resource->setStatus(Resource::STATUS_ERROR, $e->getMessage()); $this->addError(new Exception( resourceName: $resource->getName(), From e060244b01d296f97668f2705627ca38ce3b61f7 Mon Sep 17 00:00:00 2001 From: Prem Palanisamy Date: Tue, 5 May 2026 15:46:26 +0100 Subject: [PATCH 6/8] Stop createField/createIndex cleanup catches from silencing bugs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The catch (\Throwable) cleanup blocks in createField and createIndex were rewrapping any thrown exception as a Migration\Exception with a generic 'Failed to create column/index' message. With the worker's instanceof MigrationException gate, this silenced real library bugs (TypeError, RuntimeException, PDOException) from Sentry — the exact opposite of what the surrounding PR aims to do. Rethrow the original cause instead, so the safety net at import() records the real message for the user and the worker boundary routes non-MigrationException throwables to Sentry with full trace. --- src/Migration/Destinations/Appwrite.php | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/src/Migration/Destinations/Appwrite.php b/src/Migration/Destinations/Appwrite.php index e7e4fc535a..846669cb86 100644 --- a/src/Migration/Destinations/Appwrite.php +++ b/src/Migration/Destinations/Appwrite.php @@ -821,19 +821,14 @@ class Appwrite extends Destination throw new \Exception('Failed to create Column', Exception::CODE_INTERNAL); } } - } catch (\Throwable) { + } catch (\Throwable $e) { $this->dbForProject->deleteDocument('attributes', $column->getId()); if (isset($twoWayAttribute)) { $this->dbForProject->deleteDocument('attributes', $twoWayAttribute->getId()); } - throw new Exception( - resourceName: $resource->getName(), - resourceGroup: $resource->getGroup(), - resourceId: $resource->getId(), - message: 'Failed to create column', - ); + throw $e; } if ($type === UtopiaDatabase::VAR_RELATIONSHIP && $options['twoWay']) { @@ -986,12 +981,7 @@ class Appwrite extends Destination } catch (\Throwable $th) { $this->dbForProject->deleteDocument('indexes', $index->getId()); - throw new Exception( - resourceName: $resource->getName(), - resourceGroup: $resource->getGroup(), - resourceId: $resource->getId(), - message: 'Failed to create index', - ); + throw $th; } $this->dbForProject->purgeCachedDocument( From da8205e8f3e927b2b860dddc2efca0e408171116 Mon Sep 17 00:00:00 2001 From: Prem Palanisamy Date: Tue, 5 May 2026 16:50:58 +0100 Subject: [PATCH 7/8] Revert per-resource wrap rethrow; record and continue MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The earlier 'throw $e' aborted the batch on the first failure, leaving items #6-N at STATUS_PENDING and skipping the rest of the source's fetch loop. Restore the original 'absorb-and-continue' shape so every resource in the batch is attempted and recorded — failures all land in the migration report and the user retries the run cleanly. Trade-off: library bugs (TypeError, etc.) caught here are absorbed and don't reach Sentry. Acceptable — the deterministic-bug case fails the same way for every resource, so absorbing produces a uniform 'all errored' report instead of '1 errored + N pending'. User errors are still kept out of Sentry by the worker's instanceof MigrationException gate, which is the primary goal of this PR. --- src/Migration/Destinations/Appwrite.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Migration/Destinations/Appwrite.php b/src/Migration/Destinations/Appwrite.php index fd7a7c7095..38673cbbd1 100644 --- a/src/Migration/Destinations/Appwrite.php +++ b/src/Migration/Destinations/Appwrite.php @@ -400,8 +400,6 @@ class Appwrite extends Destination default => throw new \Exception('Invalid resource group', Exception::CODE_VALIDATION), }; } catch (\Throwable $e) { - // Safety net for unexpected failures — record on the migration and - // rethrow so the worker boundary can route bugs to Sentry. $resource->setStatus(Resource::STATUS_ERROR, $e->getMessage()); $this->addError(new Exception( @@ -413,7 +411,7 @@ class Appwrite extends Destination previous: $e )); - throw $e; + $responseResource = $resource; } finally { $this->dbForProject->setPreserveDates(false); } From 7d2950787011e5e97a4e3a0f6a5538e53ff1e0fc Mon Sep 17 00:00:00 2001 From: Prem Palanisamy Date: Wed, 6 May 2026 13:42:14 +0100 Subject: [PATCH 8/8] Fix message: 'Column' -> 'Attribute' limit exceeded to match main --- src/Migration/Destinations/Appwrite.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Migration/Destinations/Appwrite.php b/src/Migration/Destinations/Appwrite.php index 38673cbbd1..d8b1fef9ec 100644 --- a/src/Migration/Destinations/Appwrite.php +++ b/src/Migration/Destinations/Appwrite.php @@ -966,12 +966,12 @@ class Appwrite extends Destination } catch (LimitException $e) { $this->dbForProject->deleteDocument(self::META_ATTRIBUTES, $column->getId()); - $resource->setStatus(Resource::STATUS_ERROR, 'Column limit exceeded'); + $resource->setStatus(Resource::STATUS_ERROR, 'Attribute limit exceeded'); $this->addError(new Exception( resourceName: $resource->getName(), resourceGroup: $resource->getGroup(), resourceId: $resource->getId(), - message: 'Column limit exceeded', + message: 'Attribute limit exceeded', previous: $e, )); return false;