diff --git a/src/Keboola/Console/Command/DeleteOrganizationOwnerlessWorkspaces.php b/src/Keboola/Console/Command/DeleteOrganizationOwnerlessWorkspaces.php index 562c17a..593b3ac 100644 --- a/src/Keboola/Console/Command/DeleteOrganizationOwnerlessWorkspaces.php +++ b/src/Keboola/Console/Command/DeleteOrganizationOwnerlessWorkspaces.php @@ -182,7 +182,13 @@ protected function execute(InputInterface $input, OutputInterface $output): int $components->deleteConfiguration($session['componentId'], $session['configurationId']); $components->deleteConfiguration($session['componentId'], $session['configurationId']); } catch (StorageClientException $e) { - if ($e->getStringCode() !== 'storage.components.cannotDeleteConfiguration') { + // The configuration may already be gone (notFound) or refuse permanent + // deletion (cannotDeleteConfiguration). Either way its editor session can + // still linger, so clean it up and continue instead of aborting the run. + if (!in_array($e->getStringCode(), [ + 'storage.configuration.notFound', + 'storage.components.cannotDeleteConfiguration', + ], true)) { throw $e; } $editorClient->deleteSession($session['id']); @@ -273,7 +279,12 @@ protected function execute(InputInterface $input, OutputInterface $output): int $storageComponents->deleteConfiguration('keboola.sandboxes', $app->getConfigId()); $storageComponents->deleteConfiguration('keboola.sandboxes', $app->getConfigId()); } catch (StorageClientException $e) { - if ($e->getStringCode() !== 'storage.components.cannotDeleteConfiguration') { + // Already trashed/purged (notFound) or unpurgeable + // (cannotDeleteConfiguration) — nothing left to do here. + if (!in_array($e->getStringCode(), [ + 'storage.configuration.notFound', + 'storage.components.cannotDeleteConfiguration', + ], true)) { throw $e; } } diff --git a/src/Keboola/Console/Command/DeleteOwnerlessWorkspaces.php b/src/Keboola/Console/Command/DeleteOwnerlessWorkspaces.php index cda0c99..7bb6c79 100644 --- a/src/Keboola/Console/Command/DeleteOwnerlessWorkspaces.php +++ b/src/Keboola/Console/Command/DeleteOwnerlessWorkspaces.php @@ -128,7 +128,13 @@ protected function execute(InputInterface $input, OutputInterface $output): int $components->deleteConfiguration($componentId, $configurationId); $components->deleteConfiguration($componentId, $configurationId); } catch (StorageClientException $e) { - if ($e->getStringCode() !== 'storage.components.cannotDeleteConfiguration') { + // The configuration may already be gone (notFound) or refuse permanent + // deletion (cannotDeleteConfiguration). Either way its editor session can + // still linger, so clean it up and continue instead of aborting the run. + if (!in_array($e->getStringCode(), [ + 'storage.configuration.notFound', + 'storage.components.cannotDeleteConfiguration', + ], true)) { throw $e; } $editorClient->deleteSession($sessionId); @@ -209,7 +215,12 @@ protected function execute(InputInterface $input, OutputInterface $output): int $storageComponents->deleteConfiguration('keboola.sandboxes', $app->getConfigId()); $storageComponents->deleteConfiguration('keboola.sandboxes', $app->getConfigId()); } catch (StorageClientException $e) { - if ($e->getStringCode() !== 'storage.components.cannotDeleteConfiguration') { + // Already trashed/purged (notFound) or unpurgeable + // (cannotDeleteConfiguration) — nothing left to do here. + if (!in_array($e->getStringCode(), [ + 'storage.configuration.notFound', + 'storage.components.cannotDeleteConfiguration', + ], true)) { throw $e; } }